From 6fecec8e4e369dfc7f54b3592c4d781b8ab85665 Mon Sep 17 00:00:00 2001 From: Gareth Evans Date: Thu, 2 Feb 2017 12:41:36 +0000 Subject: [PATCH] Add image_free to tidy-up --- image.cc | 6 +++++- image.hh | 1 + outputs.cc | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/image.cc b/image.cc index da67bef..ecee80d 100644 --- a/image.cc +++ b/image.cc @@ -106,7 +106,7 @@ int image_init(PIMAGE_CTX ctx, \ return success; } /* - * image_add_pixel, image_set_pixel, image_get_pixel, image_write + * image_add_pixel, image_set_pixel, image_get_pixel, image_write, image_free * Various setters ad getters for assigning pixel data. image_write * takes an open file handle and writes image data to it. * These functions simply wrap the underlying format-specific functions @@ -134,6 +134,10 @@ int image_write(PIMAGE_CTX ctx, FILE *fd){ if(ctx->initialized != 1) return EINVAL; return dt->write(ctx,fd); } +void image_free(PIMAGE_CTX ctx){ + if(ctx->initialized != 1) return; + free(ctx->canvas); +} /* * image_get_filename diff --git a/image.hh b/image.hh index 45437d0..67812b9 100644 --- a/image.hh +++ b/image.hh @@ -36,6 +36,7 @@ int image_set_pixel(PIMAGE_CTX ctx, const size_t, const size_t, const uint8_t, c int image_get_pixel(PIMAGE_CTX ctx,const size_t,const size_t, uint8_t const*, uint8_t const*, uint8_t const*, uint8_t const*); int image_get_filename(PIMAGE_CTX, char*, size_t, char*); int image_write(PIMAGE_CTX, FILE*); +void image_free(PIMAGE_CTX); int image_set_library(char*); #define ADD_PIXEL(ctx,r,g,b) image_add_pixel((ctx),(r),(g),(b),0xff) diff --git a/outputs.cc b/outputs.cc index 6425096..b1b9202 100644 --- a/outputs.cc +++ b/outputs.cc @@ -749,6 +749,8 @@ void DoRxdPwr(char *filename, unsigned char geo, unsigned char kml, fflush(fd); + image_free(&ctx); + if( filename != NULL ) { fclose(fd); fd = NULL;