aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2014-10-20 12:23:27 +0200
committerThomas White <taw@physics.org>2015-01-29 13:23:38 +0100
commit0cf8b25040bf17328e737945dae598b3dbfe9313 (patch)
tree70fa58ac55259cb4cf7301e7e14aa90b76820c99 /src
parent286e7e985d27ce657da7e8318a9b61ecc0b9878b (diff)
Window may expand at the same time as a frame gets skipped
Diffstat (limited to 'src')
-rw-r--r--src/whirligig.c20
1 files changed, 13 insertions, 7 deletions
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; i<sf; i++ ) {
win[ws-sf+i].serial = 0;
ser[ws-sf+i] = -1;
+ mat[ws-sf+i] = NULL;
}
- pos = ws - 1;
+ }
+ for ( i=0; i<sf; i++ ) {
+ win[ws-sf+i].serial = 0;
+ ser[ws-sf+i] = -1;
+ mat[ws-sf+i] = NULL;
}
+ pos = ws-1;
+
} else {
pos = ws-(win[ws-1].serial - cur->serial)-1;