From 0cf8b25040bf17328e737945dae598b3dbfe9313 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 20 Oct 2014 12:23:27 +0200 Subject: Window may expand at the same time as a frame gets skipped --- src/whirligig.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/whirligig.c') diff --git a/src/whirligig.c b/src/whirligig.c index 861c2d01..6f5e82b4 100644 --- a/src/whirligig.c +++ b/src/whirligig.c @@ -373,7 +373,7 @@ static int add_to_window(struct image *cur, struct image **pwin, signed int **pser, IntegerMatrix ***pmat, int *pws) { - int sf, pos; + int pos; struct image *win = *pwin; signed int *ser = *pser; IntegerMatrix **mat = *pmat; @@ -381,11 +381,13 @@ static int add_to_window(struct image *cur, struct image **pwin, if ( cur->serial > win[ws-1].serial ) { - int i; + int i, sf; + + sf = cur->serial - win[ws-1].serial; if ( series_fills_window(ser, ws) ) { - ws++; + ws += sf; win = realloc(win, ws*sizeof(struct image)); ser = realloc(ser, ws*sizeof(signed int)); mat = realloc(mat, ws*sizeof(IntegerMatrix *)); @@ -398,12 +400,9 @@ static int add_to_window(struct image *cur, struct image **pwin, *pser = ser; *pmat = mat; - pos = ws-1; } else { - sf = cur->serial - win[ws-1].serial; - memmove(win, win+sf, (ws-sf)*sizeof(struct image)); memmove(ser, ser+sf, (ws-sf)*sizeof(signed int)); memmove(mat, mat+sf, (ws-sf)*sizeof(IntegerMatrix *)); @@ -411,12 +410,19 @@ static int add_to_window(struct image *cur, struct image **pwin, for ( i=0; iserial)-1; -- cgit v1.2.3