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;
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));
}
#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
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 **) ®ister_class);
free(lowercase_name);
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 */
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);
#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;
}
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;
}
#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);
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
}
-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);
zval_dtor(*zval_ptr);
safe_free_zval_ptr(*zval_ptr);
}
+ return 1;
}
}
-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;
ZEND_API void zend_hash_destroy(HashTable *ht)
{
Bucket *p, *q;
+ int delete_bucket;
p = ht->pListHead;
while (p != NULL) {
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);
}
Bucket *pListHead;
Bucket *pListTail;
Bucket **arBuckets;
- void (*pDestructor) (void *pData);
+ int (*pDestructor) (void *pData);
unsigned char persistent;
} 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);
}
-void list_entry_destructor(void *ptr)
+int list_entry_destructor(void *ptr)
{
list_entry *le = (list_entry *) ptr;
list_destructors_entry *ld;
} 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;
} else {
zend_error(E_WARNING,"Unknown persistent list entry type in module shutdown (%d)",le->type);
}
+ return 1;
}
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);
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
}
-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:
/* 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:
zend_hash_destroy(&ce->default_properties);
break;
}
+ return 1;
}
}
-ZEND_API void zval_dtor(zval *zvalue)
+ZEND_API int zval_dtor(zval *zvalue)
{
if (zvalue->type==IS_LONG) {
return;
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);