summaryrefslogtreecommitdiff
path: root/codec
diff options
context:
space:
mode:
authorAntonin Descampe <antonin@gmail.com>2004-08-06 14:13:51 +0000
committerAntonin Descampe <antonin@gmail.com>2004-08-06 14:13:51 +0000
commitbc5c5115cbd4b5d6500348f7af2fa49e02b216ce (patch)
tree66c869d78bf9a64845e59a3df7a36330595c7e26 /codec
parent61ac18531a62bcc31552875d2d9c5458bac452e2 (diff)
* Inserted tool for memory leaks fixing in debug mode
* Fixed some memory leaks in the decoder (some are still present when multiple tiles!)
Diffstat (limited to 'codec')
-rw-r--r--codec/image_to_j2k.c15
-rw-r--r--codec/j2k_to_image.c24
2 files changed, 35 insertions, 4 deletions
diff --git a/codec/image_to_j2k.c b/codec/image_to_j2k.c
index 54bd0c92..e7047026 100644
--- a/codec/image_to_j2k.c
+++ b/codec/image_to_j2k.c
@@ -26,6 +26,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+//MEMORY LEAK
+#ifdef _DEBUG
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h> // Must be included first
+#include <crtdbg.h>
+#endif
+//MEM
+
#include <openjpeg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -895,5 +903,12 @@ int main(int argc, char **argv)
free(cp.tcps[tileno].tccps);
free(cp.tcps);
+
+ //MEMORY LEAK
+ #ifdef _DEBUG
+ _CrtDumpMemoryLeaks();
+ #endif
+ //MEM
+
return 0;
}
diff --git a/codec/j2k_to_image.c b/codec/j2k_to_image.c
index 53104736..f1534d53 100644
--- a/codec/j2k_to_image.c
+++ b/codec/j2k_to_image.c
@@ -25,6 +25,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+//MEMORY LEAK
+#ifdef _DEBUG
+#define _CRTDBG_MAP_ALLOC
+#include <stdlib.h> // Must be included first
+#include <crtdbg.h>
+#endif
+//MEM
+
#include <openjpeg.h>
@@ -39,9 +47,9 @@ int ceildiv(int a, int b)
int main(int argc, char **argv)
{
- FILE *f;
- char *src, *src_name;
- char *dest, S1, S2, S3;
+ FILE *f=NULL;
+ char *src=NULL, *src_name=NULL;
+ char *dest=NULL, S1, S2, S3;
int len;
j2k_image_t img;
@@ -50,7 +58,7 @@ int main(int argc, char **argv)
int w, wr, wrr, h, hr, hrr, max;
int i, image_type = -1, compno, pad, j;
int adjust;
- jp2_struct_t *jp2_struct;
+ jp2_struct_t *jp2_struct=NULL;
if (argc < 3) {
fprintf(stderr,
@@ -553,5 +561,13 @@ int main(int argc, char **argv)
break;
}
+ j2k_dec_release();
+
+ //MEMORY LEAK
+ #ifdef _DEBUG
+ _CrtDumpMemoryLeaks();
+ #endif
+ //MEM
+
return 0;
}