mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
Fix compilation when checkpoints are enabled.
- Include string.h in checkpoint.h - Check return values of fgets calls in checkpoint.h. - Replace variable length array in image.c by a dynamically allocated array. - Add -DCHECKPOINTS to CFLAGS in Makefile when CHECKPOINTS is defined.
This commit is contained in:
parent
6eb89a2813
commit
581f740c59
|
@ -104,6 +104,10 @@ ifndef KVZ_DISABLE_ASM
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifdef CHECKPOINTS
|
||||||
|
CFLAGS += -DCHECKPOINTS
|
||||||
|
endif
|
||||||
|
|
||||||
# Compile files in strategy directories with appropriate flags.
|
# Compile files in strategy directories with appropriate flags.
|
||||||
ifeq ($(ARCH), ppc64)
|
ifeq ($(ARCH), ppc64)
|
||||||
strategies/altivec/%.o: EXTRA_FLAGS += -maltivec -fno-lto
|
strategies/altivec/%.o: EXTRA_FLAGS += -maltivec -fno-lto
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#error "CHECKPOINTS require assertions to be enabled!"
|
#error "CHECKPOINTS require assertions to be enabled!"
|
||||||
#endif
|
#endif
|
||||||
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ extern int g_ckpt_record; //Do we record?
|
||||||
g_ckpt_enabled = 0; \
|
g_ckpt_enabled = 0; \
|
||||||
while (!feof(g_ckpt_file)) { \
|
while (!feof(g_ckpt_file)) { \
|
||||||
char buffer_file[4096]; \
|
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) { \
|
if (strncmp(buffer_file, buffer_ckpt, 4096)==0) { \
|
||||||
g_ckpt_enabled = 1; \
|
g_ckpt_enabled = 1; \
|
||||||
break; \
|
break; \
|
||||||
|
@ -82,7 +83,7 @@ extern int g_ckpt_record; //Do we record?
|
||||||
fprintf(g_ckpt_file, str "\n", __VA_ARGS__); \
|
fprintf(g_ckpt_file, str "\n", __VA_ARGS__); \
|
||||||
} else if (g_ckpt_enabled) { \
|
} else if (g_ckpt_enabled) { \
|
||||||
char buffer_file[4096], buffer_ckpt[4096]; \
|
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__); \
|
snprintf(buffer_ckpt, 4095, str "\n", __VA_ARGS__); \
|
||||||
if (strncmp(buffer_file, buffer_ckpt, 4096)!=0) { \
|
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); \
|
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_
|
#endif //CHECKPOINT_H_
|
||||||
|
|
|
@ -477,8 +477,8 @@ void pixels_blit(const kvz_pixel * const orig, kvz_pixel * const dst,
|
||||||
assert(width <= dst_stride);
|
assert(width <= dst_stride);
|
||||||
|
|
||||||
#ifdef CHECKPOINTS
|
#ifdef CHECKPOINTS
|
||||||
|
char *buffer = malloc((3 * width + 1) * sizeof(char));
|
||||||
for (y = 0; y < height; ++y) {
|
for (y = 0; y < height; ++y) {
|
||||||
char buffer[3*width];
|
|
||||||
int p;
|
int p;
|
||||||
for (p = 0; p < width; ++p) {
|
for (p = 0; p < width; ++p) {
|
||||||
sprintf((buffer + 3*p), "%02X ", orig[y*orig_stride]);
|
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;
|
buffer[3*width] = 0;
|
||||||
CHECKPOINT("pixels_blit: %04d: %s", y, buffer);
|
CHECKPOINT("pixels_blit: %04d: %s", y, buffer);
|
||||||
}
|
}
|
||||||
|
FREE_POINTER(buffer);
|
||||||
#endif //CHECKPOINTS
|
#endif //CHECKPOINTS
|
||||||
|
|
||||||
if (orig == dst) {
|
if (orig == dst) {
|
||||||
|
|
Loading…
Reference in a new issue