summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend.c12
-rw-r--r--Zend/zend_API.c2
-rw-r--r--Zend/zend_compile.c2
-rw-r--r--Zend/zend_compile.h7
-rw-r--r--Zend/zend_constants.c5
-rw-r--r--Zend/zend_constants.h4
-rw-r--r--Zend/zend_execute_API.c3
-rw-r--r--Zend/zend_hash.c13
-rw-r--r--Zend/zend_hash.h4
-rw-r--r--Zend/zend_list.c6
-rw-r--r--Zend/zend_list.h4
-rw-r--r--Zend/zend_modules.h1
-rw-r--r--Zend/zend_opcode.c8
-rw-r--r--Zend/zend_variables.c2
-rw-r--r--Zend/zend_variables.h8
15 files changed, 50 insertions, 31 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index 5f4ba6e16c..9c2b23b31f 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -203,7 +203,7 @@ static void register_standard_class()
zend_standard_class_def.name = zend_strndup("stdClass", zend_standard_class_def.name_length);
zend_standard_class_def.parent = NULL;
zend_hash_init(&zend_standard_class_def.default_properties, 0, NULL, PVAL_PTR_DTOR, 1);
- zend_hash_init(&zend_standard_class_def.function_table, 0, NULL, (void (*)(void *)) destroy_zend_function, 1);
+ zend_hash_init(&zend_standard_class_def.function_table, 0, NULL, ZEND_FUNCTION_DTOR, 1);
zend_standard_class_def.handle_function_call = NULL;
zend_standard_class_def.handle_property_get = NULL;
zend_standard_class_def.handle_property_set = NULL;
@@ -220,11 +220,11 @@ static void compiler_globals_ctor(zend_compiler_globals *compiler_globals)
zend_class_entry tmp_class;
compiler_globals->function_table = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init(compiler_globals->function_table, 100, NULL, (void (*)(void *)) destroy_zend_function, 1);
+ zend_hash_init(compiler_globals->function_table, 100, NULL, ZEND_FUNCTION_DTOR, 1);
zend_hash_copy(compiler_globals->function_table, global_function_table, NULL, &tmp_func, sizeof(zend_function));
compiler_globals->class_table = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init(compiler_globals->class_table, 10, NULL, (void (*)(void *)) destroy_zend_class, 1);
+ zend_hash_init(compiler_globals->class_table, 10, NULL, ZEND_CLASS_DTOR, 1);
zend_hash_copy(compiler_globals->class_table, global_class_table, zend_class_add_ref, &tmp_class, sizeof(zend_class_entry));
}
@@ -303,10 +303,10 @@ int zend_startup(zend_utility_functions *utility_functions, char **extensions)
#endif
GLOBAL_FUNCTION_TABLE = (HashTable *) malloc(sizeof(HashTable));
GLOBAL_CLASS_TABLE = (HashTable *) malloc(sizeof(HashTable));
- zend_hash_init(GLOBAL_FUNCTION_TABLE, 100, NULL, (void (*)(void *)) destroy_zend_function, 1);
- zend_hash_init(GLOBAL_CLASS_TABLE, 10, NULL, (void (*)(void *)) destroy_zend_class, 1);
+ zend_hash_init(GLOBAL_FUNCTION_TABLE, 100, NULL, ZEND_FUNCTION_DTOR, 1);
+ zend_hash_init(GLOBAL_CLASS_TABLE, 10, NULL, ZEND_CLASS_DTOR, 1);
register_standard_class();
- zend_hash_init(&module_registry, 50, NULL, (void (*)(void *)) module_destructor, 1);
+ zend_hash_init(&module_registry, 50, NULL, ZEND_MODULE_DTOR, 1);
zend_hash_init(&list_destructors, 50, NULL, NULL, 1);
#ifdef ZTS
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 6e30d592c7..fdda38c109 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -767,7 +767,7 @@ ZEND_API zend_class_entry *register_internal_class(zend_class_entry *class_entry
class_entry->refcount = (int *) malloc(sizeof(int));
*class_entry->refcount = 1;
zend_hash_init(&class_entry->default_properties, 0, NULL, PVAL_PTR_DTOR, 1);
- zend_hash_init(&class_entry->function_table, 0, NULL, (void (*)(void *)) destroy_zend_function, 1);
+ zend_hash_init(&class_entry->function_table, 0, NULL, ZEND_FUNCTION_DTOR, 1);
zend_hash_update(CG(class_table), lowercase_name, class_entry->name_length+1, class_entry, sizeof(zend_class_entry), (void **) &register_class);
free(lowercase_name);
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 30b0db63ab..10e4b78c16 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -1219,7 +1219,7 @@ void do_begin_class_declaration(znode *class_name, znode *parent_class_name CLS_
zend_str_tolower(CG(class_entry).name, CG(class_entry).name_length);
- zend_hash_init(&CG(class_entry).function_table, 10, NULL, (void (*)(void *)) destroy_zend_function, 0);
+ zend_hash_init(&CG(class_entry).function_table, 10, NULL, ZEND_FUNCTION_DTOR, 0);
zend_hash_init(&CG(class_entry).default_properties, 10, NULL, PVAL_PTR_DTOR, 0);
/* code for inheritance from parent class */
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index bdbaaafc9a..2568c7662e 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -350,10 +350,13 @@ ZEND_API void zend_close_file_handle(zend_file_handle *file_handle CLS_DC);
ZEND_API void zend_open_file_dtor(void *f);
END_EXTERN_C()
-ZEND_API void destroy_zend_function(zend_function *function);
-ZEND_API void destroy_zend_class(zend_class_entry *ce);
+ZEND_API int destroy_zend_function(zend_function *function);
+ZEND_API int destroy_zend_class(zend_class_entry *ce);
void zend_class_add_ref(zend_class_entry *ce);
+#define ZEND_FUNCTION_DTOR (int (*)(void *)) destroy_zend_function
+#define ZEND_CLASS_DTOR (int (*)(void *)) destroy_zend_class
+
zend_op *get_next_op(zend_op_array *op_array CLS_DC);
int get_next_op_number(zend_op_array *op_array);
int print_class(zend_class_entry *class_entry);
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c
index a533026f48..cce14b8cc7 100644
--- a/Zend/zend_constants.c
+++ b/Zend/zend_constants.c
@@ -22,12 +22,13 @@
#include "zend_globals.h"
-void free_zend_constant(zend_constant *c)
+int free_zend_constant(zend_constant *c)
{
if (!(c->flags & CONST_PERSISTENT)) {
zval_dtor(&c->value);
}
free(c->name);
+ return 1;
}
@@ -86,7 +87,7 @@ int zend_startup_constants(ELS_D)
EG(zend_constants) = (HashTable *) malloc(sizeof(HashTable));
- if (zend_hash_init(EG(zend_constants), 20, NULL, (void(*)(void *)) free_zend_constant, 1)==FAILURE) {
+ if (zend_hash_init(EG(zend_constants), 20, NULL, ZEND_CONSTANT_DTOR, 1)==FAILURE) {
return FAILURE;
}
diff --git a/Zend/zend_constants.h b/Zend/zend_constants.h
index d36ae6ba61..efc52fdb2f 100644
--- a/Zend/zend_constants.h
+++ b/Zend/zend_constants.h
@@ -41,7 +41,7 @@ typedef struct _zend_constant {
#define REGISTER_MAIN_STRINGL_CONSTANT(name,str,len,flags) zend_register_stringl_constant((name),sizeof(name),(str),(len),(flags),0 ELS_CC)
void clean_module_constants(int module_number);
-void free_zend_constant(zend_constant *c);
+int free_zend_constant(zend_constant *c);
int zend_startup_constants(ELS_D);
int zend_shutdown_constants(ELS_D);
void clean_non_persistent_constants(void);
@@ -52,4 +52,6 @@ ZEND_API void zend_register_string_constant(char *name, uint name_len, char *str
ZEND_API void zend_register_stringl_constant(char *name, uint name_len, char *strval, uint strlen, int flags, int module_number ELS_DC);
ZEND_API void zend_register_constant(zend_constant *c ELS_DC);
+#define ZEND_CONSTANT_DTOR (int (*)(void *)) free_zend_constant
+
#endif
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 9679ff92dd..924b9f32cc 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -195,7 +195,7 @@ ZEND_API inline void safe_free_zval_ptr(zval *p)
}
-ZEND_API void zval_ptr_dtor(zval **zval_ptr)
+ZEND_API int zval_ptr_dtor(zval **zval_ptr)
{
#if DEBUG_ZEND>=2
printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, (*zval_ptr)->refcount, (*zval_ptr)->refcount-1);
@@ -205,6 +205,7 @@ ZEND_API void zval_ptr_dtor(zval **zval_ptr)
zval_dtor(*zval_ptr);
safe_free_zval_ptr(*zval_ptr);
}
+ return 1;
}
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index 285cc840f8..edb8da272f 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -71,7 +71,7 @@ ZEND_API ulong hashpjw(char *arKey, uint nKeyLength)
}
-ZEND_API int zend_hash_init(HashTable *ht, uint nSize, ulong(*pHashFunction) (char *arKey, uint nKeyLength), void (*pDestructor) (void *pData),int persistent)
+ZEND_API int zend_hash_init(HashTable *ht, uint nSize, ulong(*pHashFunction) (char *arKey, uint nKeyLength), int (*pDestructor) (void *pData),int persistent)
{
uint i;
@@ -720,6 +720,7 @@ ZEND_API int zend_hash_del_key_or_index(HashTable *ht, char *arKey, uint nKeyLen
ZEND_API void zend_hash_destroy(HashTable *ht)
{
Bucket *p, *q;
+ int delete_bucket;
p = ht->pListHead;
while (p != NULL) {
@@ -727,13 +728,19 @@ ZEND_API void zend_hash_destroy(HashTable *ht)
p = p->pListNext;
if (!q->bIsPointer) {
if (ht->pDestructor) {
- ht->pDestructor(q->pData);
+ delete_bucket = ht->pDestructor(q->pData);
+ } else {
+ delete_bucket = 1;
}
if (!q->pDataPtr && q->pData) {
pefree(q->pData,ht->persistent);
}
+ } else {
+ delete_bucket = 1;
+ }
+ if (delete_bucket) {
+ pefree(q,ht->persistent);
}
- pefree(q,ht->persistent);
}
pefree(ht->arBuckets,ht->persistent);
}
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h
index fb4d59579d..e6e9a78e27 100644
--- a/Zend/zend_hash.h
+++ b/Zend/zend_hash.h
@@ -56,7 +56,7 @@ typedef struct hashtable {
Bucket *pListHead;
Bucket *pListTail;
Bucket **arBuckets;
- void (*pDestructor) (void *pData);
+ int (*pDestructor) (void *pData);
unsigned char persistent;
} HashTable;
@@ -64,7 +64,7 @@ typedef struct hashtable {
BEGIN_EXTERN_C()
/* startup/shutdown */
-ZEND_API int zend_hash_init(HashTable *ht, uint nSize, ulong(*pHashFunction) (char *arKey, uint nKeyLength), void (*pDestructor) (void *pData), int persistent);
+ZEND_API int zend_hash_init(HashTable *ht, uint nSize, ulong(*pHashFunction) (char *arKey, uint nKeyLength), int (*pDestructor) (void *pData), int persistent);
ZEND_API void zend_hash_destroy(HashTable *ht);
ZEND_API void zend_hash_clean(HashTable *ht);
diff --git a/Zend/zend_list.c b/Zend/zend_list.c
index 6285c96970..61a8abf111 100644
--- a/Zend/zend_list.c
+++ b/Zend/zend_list.c
@@ -133,7 +133,7 @@ ZEND_API void *zend_plist_find(int id, int *type)
}
-void list_entry_destructor(void *ptr)
+int list_entry_destructor(void *ptr)
{
list_entry *le = (list_entry *) ptr;
list_destructors_entry *ld;
@@ -145,10 +145,11 @@ void list_entry_destructor(void *ptr)
} else {
zend_error(E_WARNING,"Unknown list entry type in request shutdown (%d)",le->type);
}
+ return 1;
}
-void plist_entry_destructor(void *ptr)
+int plist_entry_destructor(void *ptr)
{
list_entry *le = (list_entry *) ptr;
list_destructors_entry *ld;
@@ -160,6 +161,7 @@ void plist_entry_destructor(void *ptr)
} else {
zend_error(E_WARNING,"Unknown persistent list entry type in module shutdown (%d)",le->type);
}
+ return 1;
}
diff --git a/Zend/zend_list.h b/Zend/zend_list.h
index 2e1dfc94ab..681cbf1a49 100644
--- a/Zend/zend_list.h
+++ b/Zend/zend_list.h
@@ -42,8 +42,8 @@ enum list_entry_type {
LE_DB=1000
};
-void list_entry_destructor(void *ptr);
-void plist_entry_destructor(void *ptr);
+int list_entry_destructor(void *ptr);
+int plist_entry_destructor(void *ptr);
int clean_module_resource_destructors(list_destructors_entry *ld, int *module_number);
int init_resource_list(ELS_D);
diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h
index 8609e79774..6d6b34ff44 100644
--- a/Zend/zend_modules.h
+++ b/Zend/zend_modules.h
@@ -52,4 +52,5 @@ extern void module_destructor(zend_module_entry *module);
extern int module_registry_cleanup(zend_module_entry *module);
extern int module_registry_request_startup(zend_module_entry *module);
+#define ZEND_MODULE_DTOR (int (*)(void *)) module_destructor
#endif
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index 96ff8687dc..ba351af1a7 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -99,7 +99,7 @@ void init_op_array(zend_op_array *op_array, int initial_ops_size)
}
-ZEND_API void destroy_zend_function(zend_function *function)
+ZEND_API int destroy_zend_function(zend_function *function)
{
switch (function->type) {
case ZEND_USER_FUNCTION:
@@ -109,13 +109,14 @@ ZEND_API void destroy_zend_function(zend_function *function)
/* do nothing */
break;
}
+ return 1;
}
-ZEND_API void destroy_zend_class(zend_class_entry *ce)
+ZEND_API int destroy_zend_class(zend_class_entry *ce)
{
if (--(*ce->refcount)>0) {
- return;
+ return 1;
}
switch (ce->type) {
case ZEND_USER_CLASS:
@@ -131,6 +132,7 @@ ZEND_API void destroy_zend_class(zend_class_entry *ce)
zend_hash_destroy(&ce->default_properties);
break;
}
+ return 1;
}
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index a4365435d7..26ba3dbbaf 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -47,7 +47,7 @@ ZEND_API inline void var_uninit(zval *var)
}
-ZEND_API void zval_dtor(zval *zvalue)
+ZEND_API int zval_dtor(zval *zvalue)
{
if (zvalue->type==IS_LONG) {
return;
diff --git a/Zend/zend_variables.h b/Zend/zend_variables.h
index c72990d7f5..2b276f3a59 100644
--- a/Zend/zend_variables.h
+++ b/Zend/zend_variables.h
@@ -22,14 +22,14 @@ ZEND_API int zend_print_variable(zval *var);
BEGIN_EXTERN_C()
ZEND_API int zval_copy_ctor(zval *zvalue);
-ZEND_API void zval_dtor(zval *zvalue);
+ZEND_API int zval_dtor(zval *zvalue);
END_EXTERN_C()
-ZEND_API void zval_ptr_dtor(zval **zval_ptr);
+ZEND_API int zval_ptr_dtor(zval **zval_ptr);
void zval_add_ref(zval **p);
-#define PVAL_DESTRUCTOR (void (*)(void *)) zval_dtor
-#define PVAL_PTR_DTOR (void (*)(void *)) zval_ptr_dtor
+#define PVAL_DESTRUCTOR (int (*)(void *)) zval_dtor
+#define PVAL_PTR_DTOR (int (*)(void *)) zval_ptr_dtor
#define PVAL_COPY_CTOR (void (*)(void *)) zval_copy_ctor
ZEND_API void var_reset(zval *var);