diff --git a/src/Makefile b/src/Makefile index bd1c8385..2968e494 100644 --- a/src/Makefile +++ b/src/Makefile @@ -104,6 +104,10 @@ ifndef KVZ_DISABLE_ASM endif endif +ifdef CHECKPOINTS + CFLAGS += -DCHECKPOINTS +endif + # Compile files in strategy directories with appropriate flags. ifeq ($(ARCH), ppc64) strategies/altivec/%.o: EXTRA_FLAGS += -maltivec -fno-lto diff --git a/src/checkpoint.h b/src/checkpoint.h index 95f4b620..1c315383 100644 --- a/src/checkpoint.h +++ b/src/checkpoint.h @@ -24,6 +24,7 @@ #ifdef NDEBUG #error "CHECKPOINTS require assertions to be enabled!" #endif +#include #include #include @@ -66,7 +67,7 @@ extern int g_ckpt_record; //Do we record? g_ckpt_enabled = 0; \ while (!feof(g_ckpt_file)) { \ char buffer_file[4096]; \ - fgets(buffer_file, 4095, g_ckpt_file); \ + assert(fgets(buffer_file, 4095, g_ckpt_file) != NULL); \ if (strncmp(buffer_file, buffer_ckpt, 4096)==0) { \ g_ckpt_enabled = 1; \ break; \ @@ -82,7 +83,7 @@ extern int g_ckpt_record; //Do we record? fprintf(g_ckpt_file, str "\n", __VA_ARGS__); \ } else if (g_ckpt_enabled) { \ char buffer_file[4096], buffer_ckpt[4096]; \ - fgets(buffer_file, 4095, g_ckpt_file); \ + assert(fgets(buffer_file, 4095, g_ckpt_file) != NULL); \ snprintf(buffer_ckpt, 4095, str "\n", __VA_ARGS__); \ if (strncmp(buffer_file, buffer_ckpt, 4096)!=0) { \ fprintf(stderr, "Checkpoint failed (at %ld):\nFile: %sExec: %s", ftell(g_ckpt_file), buffer_file, buffer_ckpt); \ @@ -102,4 +103,4 @@ extern int g_ckpt_record; //Do we record? -#endif //CHECKPOINT_H_ \ No newline at end of file +#endif //CHECKPOINT_H_ diff --git a/src/image.c b/src/image.c index 8a00323c..48f623ba 100644 --- a/src/image.c +++ b/src/image.c @@ -477,8 +477,8 @@ void pixels_blit(const kvz_pixel * const orig, kvz_pixel * const dst, assert(width <= dst_stride); #ifdef CHECKPOINTS + char *buffer = malloc((3 * width + 1) * sizeof(char)); for (y = 0; y < height; ++y) { - char buffer[3*width]; int p; for (p = 0; p < width; ++p) { sprintf((buffer + 3*p), "%02X ", orig[y*orig_stride]); @@ -486,6 +486,7 @@ void pixels_blit(const kvz_pixel * const orig, kvz_pixel * const dst, buffer[3*width] = 0; CHECKPOINT("pixels_blit: %04d: %s", y, buffer); } + FREE_POINTER(buffer); #endif //CHECKPOINTS if (orig == dst) {