Browse Source

better error control in fimg_destroy

master
Tonton Th 4 years ago
parent
commit
83f80ad496
  1. 11
      lib/fimg-core.c

11
lib/fimg-core.c

@ -106,7 +106,6 @@ return 0; @@ -106,7 +106,6 @@ return 0;
}
/* --------------------------------------------------------------------- */
int fimg_destroy(FloatImg *fimg)
{
@ -114,10 +113,18 @@ int fimg_destroy(FloatImg *fimg) @@ -114,10 +113,18 @@ int fimg_destroy(FloatImg *fimg)
fprintf(stderr, ">>> %-25s ( %p )\n", __func__, fimg);
#endif
if (NULL == fimg) {
fprintf(stderr, "%s : parameter is null\n", __func__);
return -1;
}
if ( ! fimg_type_is_valid(fimg->type) ) {
return -2;
}
if (NULL == fimg->R) {
fprintf(stderr, "%s : %p already freeed\n", __func__, fimg);
return -3;
}
free(fimg->R);
memset(fimg, 0, sizeof(FloatImg));

Loading…
Cancel
Save