summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
Diffstat (limited to 'hl')
-rw-r--r--hl/examples/ex_image2.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/hl/examples/ex_image2.c b/hl/examples/ex_image2.c
index 76c3a75..3276f7c 100644
--- a/hl/examples/ex_image2.c
+++ b/hl/examples/ex_image2.c
@@ -26,7 +26,7 @@
#define PAL_ENTRIES 256
static int read_data(const char* file_name, hsize_t *width, hsize_t *height );
-unsigned char *gbuf = 0; /* global buffer for image data */
+unsigned char *gbuf = NULL; /* global buffer for image data */
int main( void )
{
@@ -79,18 +79,25 @@ int main( void )
/* make dataset */
status=H5IMmake_image_24bit( file_id, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", gbuf );
- if (gbuf) {
- free(gbuf);
- gbuf = NULL;
- }
/* close the file. */
H5Fclose( file_id );
+ if(gbuf) {
+ free(gbuf);
+ gbuf = NULL;
+ }
+
return 0;
out:
printf("Error on return function...Exiting\n");
+
+ if(gbuf) {
+ free(gbuf);
+ gbuf = NULL;
+ }
+
return 1;
}