ref: 2f144ccad768088ec811f0945eb8611fbc1e0218
parent: aa05c704e7f080980bfd3ac3483d3660b7cbc29e
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue Mar 24 13:45:06 EDT 2020
waveform: (re)allocate image when size changes
--- a/waveform/waveform.c
+++ b/waveform/waveform.c
@@ -141,9 +141,11 @@
free(b);
r.max.x = y;
r.max.y = 128;
- freeimage(w->image);
- if ((w->image = allocimage(display, r, GREY1, 0, DNofill)) == nil)
- return -1;
+ if (w->image == nil || !eqrect(r, w->image->r)) {
+ freeimage(w->image);
+ if ((w->image = allocimage(display, r, GREY1, 0, DNofill)) == nil)
+ return -1;
+ }
if (loadimage(w->image, r, (void*)p, 128*y) < 0)
fprint(2, "failed: %r\n");