summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend.h4
-rw-r--r--Zend/zend_API.h1
-rw-r--r--Zend/zend_alloc.c19
-rw-r--r--Zend/zend_compile.c1
-rw-r--r--Zend/zend_execute.c1
-rw-r--r--Zend/zend_globals.h3
-rw-r--r--Zend/zend_operators.c1
7 files changed, 25 insertions, 5 deletions
diff --git a/Zend/zend.h b/Zend/zend.h
index d99fae9cc9..b066b47e12 100644
--- a/Zend/zend.h
+++ b/Zend/zend.h
@@ -284,10 +284,6 @@ END_EXTERN_C()
#define INIT_ZVAL(z) z = zval_used_for_init;
-#define ALLOC_ZVAL(z) (z) = (zval *) emalloc(sizeof(zval))
-
-#define FREE_ZVAL(z) efree(z)
-
#define ALLOC_INIT_ZVAL(zp) \
ALLOC_ZVAL(zp); \
INIT_ZVAL(*zp);
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index 070bb09fcc..46054a8fd7 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -23,6 +23,7 @@
#include "modules.h"
#include "zend_list.h"
+#include "zend_zval_alloc.h"
#define ZEND_NAMED_FUNCTION(name) void name(INTERNAL_FUNCTION_PARAMETERS)
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c
index 7bcb8d1ef3..a47afae192 100644
--- a/Zend/zend_alloc.c
+++ b/Zend/zend_alloc.c
@@ -23,6 +23,7 @@
#include "zend.h"
#include "zend_alloc.h"
#include "zend_globals.h"
+#include "zend_zval_alloc.h"
#ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif
@@ -31,7 +32,7 @@
#endif
#ifndef ZTS
-static zend_alloc_globals alloc_globals;
+zend_alloc_globals alloc_globals;
#endif
@@ -321,6 +322,10 @@ ZEND_API void start_memory_manager(ALS_D)
AG(memory_exhausted)=0;
#endif
+#if ZEND_DEBUG
+ AG(zval_list_head) = NULL;
+#endif
+
memset(AG(cache_count),0,MAX_CACHED_MEMORY*sizeof(unsigned char));
}
@@ -330,9 +335,21 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache)
zend_mem_header *p, *t;
#if ZEND_DEBUG
int had_leaks=0;
+#else
+ zend_zval_list_entry *zval_list_entry, *next_zval_list_entry;
#endif
ALS_FETCH();
+#if !ZEND_DEBUG
+ zval_list_entry = AG(zval_list_head);
+ while (zval_list_entry) {
+ next_zval_list_entry = zval_list_entry->next;
+ efree(zval_list_entry);
+ zval_list_entry = next_zval_list_entry;
+ }
+ AG(zval_list_head) = NULL;
+#endif
+
p=AG(head);
t=AG(head);
while (t) {
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 38be21fe3f..64872a1d0d 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -25,6 +25,7 @@
#include "zend_API.h"
#include "zend_variables.h"
#include "zend_operators.h"
+#include "zend_zval_alloc.h"
ZEND_API zend_op_array *(*zend_compile_files)(int mark_as_ref CLS_DC, int file_count, ...);
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 8a1bf5a74f..eb23e33826 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -30,6 +30,7 @@
#include "zend_operators.h"
#include "zend_constants.h"
#include "zend_extensions.h"
+#include "zend_zval_alloc.h"
#if defined(HAVE_ALLOCA) && defined(HAVE_ALLOCA_H)
# include <alloca.h>
diff --git a/Zend/zend_globals.h b/Zend/zend_globals.h
index cae5a753d1..5a08c11a82 100644
--- a/Zend/zend_globals.h
+++ b/Zend/zend_globals.h
@@ -179,6 +179,9 @@ struct _zend_alloc_globals {
zend_mem_header *phead; /* persistent list */
void *cache[MAX_CACHED_MEMORY][MAX_CACHED_ENTRIES];
unsigned char cache_count[MAX_CACHED_MEMORY];
+#if !ZEND_DEBUG
+ void *zval_list_head;
+#endif
#if MEMORY_LIMIT
unsigned int memory_limit;
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 6256155f3e..894d929d00 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -29,6 +29,7 @@
#include "zend_variables.h"
#include "zend_globals.h"
#include "zend_list.h"
+#include "zend_zval_alloc.h"
#if WITH_BCMATH
#include "functions/number.h"