From b18ffbd08ab758561b21133c8d7cd1b8e8c4f057 Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Tue, 9 Oct 2012 09:44:24 +0000 Subject: [PATCH] [trunk] Use opj_malloc/opj_free in jpip bin Update issue 177 --- src/bin/jpip/opj_jpip_compress.c | 39 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/bin/jpip/opj_jpip_compress.c b/src/bin/jpip/opj_jpip_compress.c index 1b230744..d3e96673 100644 --- a/src/bin/jpip/opj_jpip_compress.c +++ b/src/bin/jpip/opj_jpip_compress.c @@ -54,6 +54,7 @@ #include "opj_config.h" #include "openjpeg.h" +#include "openjpip.h" #include "opj_getopt.h" #include "convert.h" #include "index.h" @@ -415,7 +416,7 @@ int get_file_format(char *filename) { char * get_file_name(char *name){ char *fname; - fname= (char*)malloc(OPJ_PATH_LEN*sizeof(char)); + fname= (char*)opj_malloc(OPJ_PATH_LEN*sizeof(char)); fname= strtok(name,"."); return fname; } @@ -767,7 +768,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters, parameters->tcp_numlayers = numlayers; numresolution = parameters->numresolution; matrix_width = numresolution * 3; - parameters->cp_matrice = (int *) malloc(numlayers * matrix_width * sizeof(int)); + parameters->cp_matrice = (int *) opj_malloc(numlayers * matrix_width * sizeof(int)); s = s + 2; for (i = 0; i < numlayers; i++) { @@ -995,7 +996,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters, case 'C': /* add a comment */ { - parameters->cp_comment = (char*)malloc(strlen(opj_optarg) + 1); + parameters->cp_comment = (char*)opj_malloc(strlen(opj_optarg) + 1); if(parameters->cp_comment) { strcpy(parameters->cp_comment, opj_optarg); } @@ -1024,7 +1025,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters, case 'z': /* Image Directory path */ { - img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1); + img_fol->imgdirpath = (char*)opj_malloc(strlen(opj_optarg) + 1); strcpy(img_fol->imgdirpath,opj_optarg); img_fol->set_imgdir=1; } @@ -1081,7 +1082,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters, fseek(lFile,0,SEEK_END); lStrLen = ftell(lFile); fseek(lFile,0,SEEK_SET); - lMatrix = (char *) malloc(lStrLen + 1); + lMatrix = (char *) opj_malloc(lStrLen + 1); fread(lMatrix, lStrLen, 1, lFile); fclose(lFile); @@ -1102,7 +1103,7 @@ int parse_cmdline_encoder(int argc, char **argv, opj_cparameters_t *parameters, lNbComp = (int) (sqrt(4*lNbComp + 1)/2. - 0.5); lMctComp = lNbComp * lNbComp; lTotalComp = lMctComp + lNbComp; - lSpace = (float *) malloc(lTotalComp * sizeof(float)); + lSpace = (float *) opj_malloc(lTotalComp * sizeof(float)); lCurrentDoublePtr = lSpace; for (i=0;i> */ #ifdef USE_JPWL - parameters.cp_comment = (char*)malloc(clen+strlen(version)+11); + parameters.cp_comment = (char*)opj_malloc(clen+strlen(version)+11); sprintf(parameters.cp_comment,"%s%s with JPWL", comment, version); #else - parameters.cp_comment = (char*)malloc(clen+strlen(version)+1); + parameters.cp_comment = (char*)opj_malloc(clen+strlen(version)+1); sprintf(parameters.cp_comment,"%s%s", comment, version); #endif /* <filename_buf = (char*)malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/ - dirptr->filename = (char**) malloc(num_images*sizeof(char*)); + dirptr->filename_buf = (char*)opj_malloc(num_images*OPJ_PATH_LEN*sizeof(char)); /* Stores at max 10 image file names*/ + dirptr->filename = (char**) opj_malloc(num_images*sizeof(char*)); if(!dirptr->filename_buf){ return 0; } @@ -1839,7 +1840,7 @@ int main(int argc, char **argv) { if( bUseTiles ) { OPJ_BYTE *l_data; OPJ_UINT32 l_data_size = 512*512*3; - l_data = (OPJ_BYTE*) malloc( l_data_size * sizeof(OPJ_BYTE)); + l_data = (OPJ_BYTE*) opj_malloc( l_data_size * sizeof(OPJ_BYTE)); memset(l_data, 0, l_data_size ); assert( l_data ); for (i=0;i