From d55af7fe7ea3e160fd0bb62301eb0f3d6533e7d6 Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Fri, 21 Jul 2006 20:03:07 +0000 Subject: [PATCH] ENH: Cannot assign const char* into a char*. At same time upgrade OpenJPEG version to proper one --- codec/image_to_j2k.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/codec/image_to_j2k.c b/codec/image_to_j2k.c index cbf0a461..77bb3362 100644 --- a/codec/image_to_j2k.c +++ b/codec/image_to_j2k.c @@ -631,7 +631,6 @@ void info_callback(const char *msg, void *client_data) { int main(int argc, char **argv) { bool bSuccess; - bool delete_comment = true; opj_cparameters_t parameters; /* compression parameters */ opj_event_mgr_t event_mgr; /* event manager */ opj_image_t *image = NULL; @@ -654,9 +653,9 @@ int main(int argc, char **argv) { } if(parameters.cp_comment == NULL) { - parameters.cp_comment = "Created by OpenJPEG version 0.9"; - /* no need to delete parameters.cp_comment on exit */ - delete_comment = false; + const char comment[] = "Created by OpenJPEG version 1.0"; + parameters.cp_comment = (char*)malloc(strlen(comment)+1); + strcpy(parameters.cp_comment, comment); } /* decode the source image */ @@ -778,9 +777,7 @@ int main(int argc, char **argv) { } /* free user parameters structure */ - if(delete_comment) { - if(parameters.cp_comment) free(parameters.cp_comment); - } + if(parameters.cp_comment) free(parameters.cp_comment); if(parameters.cp_matrice) free(parameters.cp_matrice); /* free image data */