[trunk] Fix Java binding compilation. Need to link against openmj2 for now to resolve...
[openjpeg.git] / wrapping / java / openjp2 / JavaOpenJPEGDecoder.c
index c60f154d24afe2add3de289ef0e02357c3a23788..321b592f7cbfd1022add32076f1ff5ec95a9fbff 100644 (file)
@@ -37,6 +37,7 @@
 #include <math.h>\r
 \r
 #include "openjpeg.h"\r
+#include "opj_includes.h"\r
 #include "opj_getopt.h"\r
 #include "convert.h"\r
 #include "dirent.h"\r
@@ -338,7 +339,7 @@ int parse_cmdline_decoder(int argc, char **argv, opj_dparameters_t *parameters,i
 \r
                        case 'y':                       /* Image Directory path */\r
                                {\r
-                                       img_fol->imgdirpath = (char*)malloc(strlen(opj_optarg) + 1);\r
+                                       img_fol->imgdirpath = (char*)opj_malloc(strlen(opj_optarg) + 1);\r
                                        strcpy(img_fol->imgdirpath,opj_optarg);\r
                                        img_fol->set_imgdir=1;\r
                                }\r
@@ -542,7 +543,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
        /* Get the String[] containing the parameters, and converts it into a char** to simulate command line arguments.*/\r
        arraySize = (*env)->GetArrayLength(env, javaParameters);\r
        argc = (int) arraySize +1;\r
-       argv = malloc(argc*sizeof(char*));\r
+       argv = opj_malloc(argc*sizeof(char*));\r
        argv[0] = "ProgramName.exe";    /* The program name: useless*/\r
        j=0;\r
        for (i=1; i<argc; i++) {\r
@@ -596,7 +597,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
                        fseek(fsrc, 0, SEEK_END);\r
                        file_length = ftell(fsrc);\r
                        fseek(fsrc, 0, SEEK_SET);\r
-                       src = (unsigned char *) malloc(file_length);\r
+                       src = (unsigned char *) opj_malloc(file_length);\r
                        fread(src, 1, file_length, fsrc);\r
                        fclose(fsrc);\r
                        /*printf("C: %d bytes read from file\n",file_length);*/\r
@@ -712,7 +713,7 @@ JNIEXPORT jint JNICALL Java_org_openJpeg_OpenJPEGJavaDecoder_internalDecodeJ2Kto
 \r
                /* free the memory containing the code-stream */\r
                if (parameters.infile && parameters.infile[0]!='\0') {\r
-                       free(src);\r
+                       opj_free(src);\r
                } else {\r
                        (*env)->ReleaseByteArrayElements(env, jba, jbBody, 0);\r
                }\r