minor tweaks

This commit is contained in:
Tonton Th 2019-12-21 14:42:55 +01:00
parent 03cfbf8217
commit 746e8d12f6
1 changed files with 7 additions and 3 deletions

View File

@ -102,6 +102,9 @@ fclose(fp);
return 0;
}
/* ---------------------------------------------------------------- */
/*
* load a dump in a pre-allocated FloatImg
*/
int fimg_load_from_dump(char *fname, FloatImg *where)
{
FILE *fp;
@ -113,13 +116,14 @@ fprintf(stderr, ">>> %-25s ( '%s' %p )\n", __func__, fname, head);
#endif
if (NULL==(fp = fopen(fname, "r"))) {
perror(fname); exit(1);
perror(fname);
return -15;
}
foo = fread(&filehead, sizeof(FimgFileHead), 1, fp);
if (1 != foo) {
fprintf(stderr, "%s: short read on '%s'\n", __func__, fname);
fclose(fp);
return -1;
return -16;
}
/* check compatibility */
@ -135,7 +139,7 @@ if ( (filehead.w != where->width) ||
nbre = filehead.w*filehead.h*filehead.t; /* ugly quirk */
foo = fread(where->R, sizeof(float), nbre, fp);
if (nbre != foo) {
fprintf(stderr, "%s: err read '%s' : %d\n", __func__, fname, errno);
fprintf(stderr, "%s: err read '%s' : %d\n", __func__, fname, foo);
fclose(fp);
return -18;
}