diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2002-11-18 12:31:39 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2002-11-18 12:31:39 +0000 |
commit | d9ecd30cc49d8a2b13e59ddd2cc0996845260234 (patch) | |
tree | f0e9dd76c89fcce391fd0ca889f49f3806f6ad42 | |
parent | f8026b7453ec6e9dd9dd813648c850d4ada85b71 (diff) | |
download | php-git-d9ecd30cc49d8a2b13e59ddd2cc0996845260234.tar.gz |
Changed memory allocation wrappers to macros, so that it is possible to see
where the memory leak is happening.
-rw-r--r-- | ext/gd/libgd/gd_jpeg.c | 1 | ||||
-rw-r--r-- | ext/gd/libgd/gd_png.c | 3 | ||||
-rw-r--r-- | ext/gd/libgd/gdhelpers.c | 32 | ||||
-rw-r--r-- | ext/gd/libgd/gdhelpers.h | 10 |
4 files changed, 9 insertions, 37 deletions
diff --git a/ext/gd/libgd/gd_jpeg.c b/ext/gd/libgd/gd_jpeg.c index b0bfb0a065..7ea923b25a 100644 --- a/ext/gd/libgd/gd_jpeg.c +++ b/ext/gd/libgd/gd_jpeg.c @@ -29,6 +29,7 @@ /* JCE: arrange HAVE_LIBJPEG so that it can be set in gd.h */ #ifdef HAVE_LIBJPEG #include "gdhelpers.h" +#undef HAVE_STDLIB_H /* 1.8.1: remove dependency on jinclude.h */ #include "jpeglib.h" diff --git a/ext/gd/libgd/gd_png.c b/ext/gd/libgd/gd_png.c index 1c91eaa16c..adc9b46c57 100644 --- a/ext/gd/libgd/gd_png.c +++ b/ext/gd/libgd/gd_png.c @@ -7,8 +7,9 @@ /* JCE: Arrange HAVE_LIBPNG so that it can be set in gd.h */ #ifdef HAVE_LIBPNG -#include "gdhelpers.h" + #include "png.h" /* includes zlib.h and setjmp.h */ +#include "gdhelpers.h" #define TRUE 1 #define FALSE 0 diff --git a/ext/gd/libgd/gdhelpers.c b/ext/gd/libgd/gdhelpers.c index 32620e8551..ae2428dfcd 100644 --- a/ext/gd/libgd/gdhelpers.c +++ b/ext/gd/libgd/gdhelpers.c @@ -2,8 +2,6 @@ #include "config.h" #endif -#include "php.h" - #include "gd.h" #include "gdhelpers.h" #include <stdlib.h> @@ -76,33 +74,3 @@ gd_strtok_r (char *s, char *sep, char **state) *state = s; return result; } - -void * -gdCalloc (size_t nmemb, size_t size) -{ - return ecalloc (nmemb, size); -} - -void * -gdMalloc (size_t size) -{ - return emalloc (size); -} - -void * -gdRealloc (void *ptr, size_t size) -{ - return erealloc (ptr, size); -} - -void -gdFree (void *ptr) -{ - efree (ptr); -} - -char * -gdEstrdup (const char *ptr) -{ - return estrdup(ptr); -} diff --git a/ext/gd/libgd/gdhelpers.h b/ext/gd/libgd/gdhelpers.h index 5b27638783..bb689cbefe 100644 --- a/ext/gd/libgd/gdhelpers.h +++ b/ext/gd/libgd/gdhelpers.h @@ -2,6 +2,7 @@ #define GDHELPERS_H 1 #include <sys/types.h> +#include "php.h" /* TBB: strtok_r is not universal; provide an implementation of it. */ @@ -11,10 +12,11 @@ extern char *gd_strtok_r(char *s, char *sep, char **state); in gd.h, where callers can utilize it to correctly free memory allocated by these functions with the right version of free(). */ -void *gdCalloc(size_t nmemb, size_t size); -void *gdMalloc(size_t size); -void *gdRealloc(void *ptr, size_t size); -char *gdEstrdup(const char *ptr); +#define gdCalloc(nmemb, size) ecalloc(nmemb, size) +#define gdMalloc(size) emalloc(size) +#define gdRealloc(ptr, size) erealloc(ptr, size) +#define gdEstrdup(ptr) estrdup(ptr) +#define gdFree(ptr) efree(ptr) #endif /* GDHELPERS_H */ |