[trunk] WIP: solve some memory leak in test compare functions
This commit is contained in:
parent
436318a8c8
commit
5b93ae8628
3
CHANGES
3
CHANGES
|
@ -5,6 +5,9 @@ What's New for OpenJPEG
|
||||||
! : changed
|
! : changed
|
||||||
+ : added
|
+ : added
|
||||||
|
|
||||||
|
October 19, 2011
|
||||||
|
* [mickael] WIP: resolve some memory leak in compare functions
|
||||||
|
|
||||||
October 12, 2011
|
October 12, 2011
|
||||||
* [mickael] WIP: resolve heap corruption with p0_07.j2k (credit to Winfried)
|
* [mickael] WIP: resolve heap corruption with p0_07.j2k (credit to Winfried)
|
||||||
* [mickael] WIP: correct some memory leaks in applications functions
|
* [mickael] WIP: correct some memory leaks in applications functions
|
||||||
|
|
|
@ -321,7 +321,10 @@ double* parseToleranceValues( char* inArg, const int nbcomp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it_comp != nbcomp)
|
if (it_comp != nbcomp)
|
||||||
|
{
|
||||||
|
free(outArgs);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
return outArgs;
|
return outArgs;
|
||||||
}
|
}
|
||||||
|
@ -407,10 +410,21 @@ opj_image_t* readImageFromFilePGX(char* filename, int nbFilenamePGX, char *separ
|
||||||
// Read the pgx file corresponding to the component
|
// Read the pgx file corresponding to the component
|
||||||
image_read = pgxtoimage(filenameComponentPGX, ¶meters);
|
image_read = pgxtoimage(filenameComponentPGX, ¶meters);
|
||||||
if (!image_read)
|
if (!image_read)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Unable to load pgx file\n");
|
int it_free_data;
|
||||||
return NULL;
|
fprintf(stderr, "Unable to load pgx file\n");
|
||||||
}
|
|
||||||
|
free(param_image_read);
|
||||||
|
|
||||||
|
for (it_free_data = 0; it_free_data < it_file; it_free_data++) {
|
||||||
|
free(data[it_free_data]);
|
||||||
|
}
|
||||||
|
free(data);
|
||||||
|
|
||||||
|
free(filenameComponentPGX);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Set the image_read parameters
|
// Set the image_read parameters
|
||||||
param_image_read[it_file].x0 = 0;
|
param_image_read[it_file].x0 = 0;
|
||||||
|
@ -498,10 +512,10 @@ int main(int argc, char **argv)
|
||||||
if( parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE )
|
if( parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE )
|
||||||
{
|
{
|
||||||
comparePGXimages_help_display();
|
comparePGXimages_help_display();
|
||||||
if (!inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
if (inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
||||||
if (!inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
if (inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
||||||
if (!inParam.base_filename) free(inParam.base_filename);
|
if (inParam.base_filename) free(inParam.base_filename);
|
||||||
if (!inParam.test_filename) free(inParam.test_filename);
|
if (inParam.test_filename) free(inParam.test_filename);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,10 +574,10 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
if (inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
||||||
if (!inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
if (inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
||||||
if (!inParam.base_filename) free(inParam.base_filename);
|
if (inParam.base_filename) free(inParam.base_filename);
|
||||||
if (!inParam.test_filename) free(inParam.test_filename);
|
if (inParam.test_filename) free(inParam.test_filename);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,10 +596,10 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
if (inParam.tabMSEvalues) free(inParam.tabMSEvalues);
|
||||||
if (!inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
if (inParam.tabPEAKvalues) free(inParam.tabPEAKvalues);
|
||||||
if (!inParam.base_filename) free(inParam.base_filename);
|
if (inParam.base_filename) free(inParam.base_filename);
|
||||||
if (!inParam.test_filename) free(inParam.test_filename);
|
if (inParam.test_filename) free(inParam.test_filename);
|
||||||
free(filenamePNGbase);
|
free(filenamePNGbase);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,18 +127,52 @@ int main(int argc, char **argv)
|
||||||
if (parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE)
|
if (parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE)
|
||||||
{
|
{
|
||||||
compareRAWimages_help_display();
|
compareRAWimages_help_display();
|
||||||
|
|
||||||
|
/* Free Memory */
|
||||||
|
if (inParam.base_filename){
|
||||||
|
free(inParam.base_filename);
|
||||||
|
inParam.base_filename = NULL;
|
||||||
|
}
|
||||||
|
if (inParam.test_filename){
|
||||||
|
free(inParam.test_filename);
|
||||||
|
inParam.test_filename = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_test = fopen(inParam.test_filename, "rb");
|
file_test = fopen(inParam.test_filename, "rb");
|
||||||
if (!file_test) {
|
if (!file_test) {
|
||||||
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.test_filename);
|
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.test_filename);
|
||||||
|
|
||||||
|
/* Free Memory */
|
||||||
|
if (inParam.base_filename){
|
||||||
|
free(inParam.base_filename);
|
||||||
|
inParam.base_filename = NULL;
|
||||||
|
}
|
||||||
|
if (inParam.test_filename){
|
||||||
|
free(inParam.test_filename);
|
||||||
|
inParam.test_filename = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
file_base = fopen(inParam.base_filename, "rb");
|
file_base = fopen(inParam.base_filename, "rb");
|
||||||
if (!file_base) {
|
if (!file_base) {
|
||||||
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.base_filename);
|
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.base_filename);
|
||||||
|
|
||||||
|
/* Free Memory */
|
||||||
|
if (inParam.base_filename){
|
||||||
|
free(inParam.base_filename);
|
||||||
|
inParam.base_filename = NULL;
|
||||||
|
}
|
||||||
|
if (inParam.test_filename){
|
||||||
|
free(inParam.test_filename);
|
||||||
|
inParam.test_filename = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(file_test);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,6 +213,16 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free Memory */
|
||||||
|
if (inParam.base_filename){
|
||||||
|
free(inParam.base_filename);
|
||||||
|
inParam.base_filename = NULL;
|
||||||
|
}
|
||||||
|
if (inParam.test_filename){
|
||||||
|
free(inParam.test_filename);
|
||||||
|
inParam.test_filename = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
fclose(file_test);
|
fclose(file_test);
|
||||||
fclose(file_base);
|
fclose(file_base);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue