From 12b601e02b80944239ac43c23a663b2dd3ba511b Mon Sep 17 00:00:00 2001 From: nick black Date: Thu, 19 Mar 2020 08:25:08 -0400 Subject: [PATCH] fallin': always push back NULLed out subwindows I noticed while running benchmarks against ranges of widths that we failed on certain widths. I traced this down to a repeatable failure when run with the -c flag at the 104x52 resolution. At this geometry and PRNG seed, we NULLed out the first subwindow of fallin', but didn't recompress the window array. On the next loop we thus used it again, and segfaulted out. This fixes that up. We now pass 100% of the benchmarks, whereas we were failing about 3% before #407. --- src/demo/fallin.c | 8 +++++++- src/poc/zalgo.c | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/demo/fallin.c b/src/demo/fallin.c index 3090b03ff..dfdc566f4 100644 --- a/src/demo/fallin.c +++ b/src/demo/fallin.c @@ -40,7 +40,7 @@ drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){ if(y + speeds[i] >= stdy){ ncplane_destroy(ncp); arr[ranges + i] = NULL; - if(ranges + i + 1 == arrcount){ + if(ranges + i + 1 == rangee){ ranges += i + 1; break; } @@ -58,6 +58,12 @@ drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){ if(!felloff){ ncplane_move_yx(ncp, y + speeds[i], x); ++speeds[i]; + }else if(i){ + if(rangee - ranges - i){ + memmove(speeds, speeds + i, (rangee - ranges - i) * sizeof(*speeds)); + } + ranges += i; + i = 0; } nanosleep(&iterdelay, NULL); } diff --git a/src/poc/zalgo.c b/src/poc/zalgo.c index ca185801d..75667a1ba 100644 --- a/src/poc/zalgo.c +++ b/src/poc/zalgo.c @@ -16,6 +16,9 @@ int main(void){ ncplane_putstr_yx(n, 6, 0, "P⃞a⃞c⃞k⃞m⃞y⃞b⃞o⃞x⃞w⃞i⃞t⃞h⃞f⃞i⃞v⃞e⃞d⃞o⃞z⃞e⃞n⃞l⃞i⃞q⃞u⃞o⃞r⃞j⃞u⃞g⃞s⃞.⃞"); ncplane_putstr_yx(n, 7, 0, "P⃣a⃣c⃣k⃣m⃣y⃣b⃣o⃣x⃣w⃣i⃣t⃣h⃣f⃣i⃣v⃣e⃣d⃣o⃣z⃣e⃣n⃣l⃣i⃣q⃣u⃣o⃣r⃣j⃣u⃣g⃣s⃣.⃣"); ncplane_putstr_yx(n, 8, 0, "ᴘᴀᴄᴋ ᴍʏ ʙᴏx ᴡɪᴛʜ ꜰɪᴠᴇ ᴅᴏᴢᴇɴ ʟɪQᴜᴏʀ ᴊᴜɢꜱ."); + ncplane_putstr_yx(n, 9, 0, "🅝🅔🅖🅐🅣🅘🅥🅔 🅒🅘🅡🅒🅛🅔🅢 🅐🅡🅔 🅐🅛🅢🅞 🅐🅥🅐🅘🅛🅐🅑🅛🅔"); + ncplane_putstr_yx(n, 10, 0, "🄴🅂🄲🄷🄴🅆 🄲🄸🅁🄲🄻🄴🅂 🄶🄴🅃 🅂🅀🅄🄰🅁🄴🅂"); + ncplane_putstr_yx(n, 11, 0, "🅰 🅱🅴🅰🆄🆃🅸🅵🆄🅻 🆄🆂🅴 🅾🅵 🅽🅴🅶🅰🆃🅸🆅🅴 🆂🆀🆄🅰🆁🅴🆂"); notcurses_render(nc); notcurses_stop(nc); return EXIT_SUCCESS;