diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-15 10:30:46 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-15 10:30:46 +0100 |
commit | f43a3244ddb0d2789e6b097868e4472bc403a09a (patch) | |
tree | cb6d5a0d268840b55d3d258537762fc096445fac /src/util.c | |
parent | a2ed9d553a54f48f771a74280fb63f95a8b228ae (diff) | |
download | advtime-f43a3244ddb0d2789e6b097868e4472bc403a09a.tar.gz advtime-f43a3244ddb0d2789e6b097868e4472bc403a09a.tar.bz2 advtime-f43a3244ddb0d2789e6b097868e4472bc403a09a.zip |
pgm_save: Check whether file could be opened
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -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 |