|
@@ -19,25 +19,26 @@ int addFrame(char *frame) {
|
19
|
19
|
char *newMem, *oldMem = mem;
|
20
|
20
|
int i;
|
21
|
21
|
|
|
22
|
+ frameCount++;
|
|
23
|
+
|
22
|
24
|
if (oldMem != NULL) {
|
23
|
25
|
newMem = (char *)malloc(65 * frameCount);
|
24
|
26
|
if (newMem == NULL) {
|
25
|
27
|
return 1;
|
26
|
28
|
}
|
27
|
|
- memcpy(newMem, oldMem, 65 * frameCount); // Copy old frames
|
|
29
|
+ memcpy(newMem, oldMem, 65 * (frameCount - 1)); // Copy old frames
|
28
|
30
|
free(oldMem);
|
29
|
31
|
} else {
|
30
|
32
|
// oldMem == NULL
|
31
|
|
- frameCount = 0;
|
|
33
|
+ frameCount = 1;
|
32
|
34
|
newMem = (char *)malloc(65);
|
33
|
35
|
if (newMem == NULL) {
|
34
|
36
|
return 1;
|
35
|
37
|
}
|
36
|
38
|
}
|
37
|
39
|
|
38
|
|
- memcpy((newMem + (65 * frameCount)), frame, 65); // Add new frame
|
|
40
|
+ memcpy((newMem + (65 * (frameCount - 1))), frame, 65); // Add new frame
|
39
|
41
|
|
40
|
|
- frameCount++;
|
41
|
42
|
mem = newMem;
|
42
|
43
|
return 0;
|
43
|
44
|
}
|