Browse Source

Changed memory allocation wrappers to macros, so that it is possible to see

where the memory leak is happening.
experimental/threaded
Ilia Alshanetsky 24 years ago
parent
commit
d9ecd30cc4
  1. 1
      ext/gd/libgd/gd_jpeg.c
  2. 3
      ext/gd/libgd/gd_png.c
  3. 32
      ext/gd/libgd/gdhelpers.c
  4. 10
      ext/gd/libgd/gdhelpers.h

1
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"

3
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

32
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);
}

10
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 */
Loading…
Cancel
Save