summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/advtime.c6
-rw-r--r--src/util.c8
-rw-r--r--src/util.h2
3 files changed, 11 insertions, 5 deletions
diff --git a/src/advtime.c b/src/advtime.c
index e4cd9a9..402da31 100644
--- a/src/advtime.c
+++ b/src/advtime.c
@@ -113,8 +113,10 @@ main(int argc, char **argv)
if (diff > 40.0) {
snprintf(filename, BUFSIZ, "img/%04i.pgm", i);
frame_mix(frame_a, frame_b);
- pgm_save(frame_a->data, frame_a->stride, frame_a->width,
- frame_a->height, filename);
+ if (pgm_save(frame_a->data, frame_a->stride,
+ frame_a->width, frame_a->height,
+ filename) < 0)
+ exit(EXIT_FAILURE);
}
printf("\n");
diff --git a/src/util.c b/src/util.c
index 9ab6e25..d9c8f35 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3,17 +3,21 @@
#include "video_decode.h"
#include "util.h"
-void
+int
pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, char *filename)
{
FILE *f;
int i;
f = fopen(filename, "w");
+ if (f == NULL)
+ return -1;
fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255);
- for(i=0; i < ysize; i++)
+ for(i = 0; i < ysize; i++)
fwrite(buf + i * wrap, 1, xsize, f);
fclose(f);
+
+ return 0;
}
void
diff --git a/src/util.h b/src/util.h
index 8e0503a..bcc2828 100644
--- a/src/util.h
+++ b/src/util.h
@@ -1,7 +1,7 @@
#ifndef _UTIL_H_
#define _UTIL_H_
-void
+int
pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, char *filename);
/* Store half of frame_a and half of frame_b in frame_a */