Permalink
Browse files

Destructors no longer return ints, the low level problem it was inten…

…ded to solve is long gone now...
  • Loading branch information...
1 parent ec386cc commit 62114c18068610dc02b7a28e74d3d2957e3315fd @zsuraski zsuraski committed Jan 17, 2000
View
@@ -79,10 +79,9 @@ static void build_runtime_defined_function_key(zval *result, zval *name, zend_op
}
-static int zend_open_file_dtor_wrapper(zend_file_handle *fh)
+static void zend_open_file_dtor_wrapper(zend_file_handle *fh)
{
zend_open_file_dtor(fh);
- return 1;
}
@@ -104,7 +103,7 @@ void init_compiler(CLS_D ELS_DC)
init_resource_list(ELS_C);
CG(unclean_shutdown) = 0;
zend_llist_init(&CG(open_files), sizeof(zend_file_handle), (void (*)(void *)) zend_open_file_dtor, 0);
- zend_hash_init(&CG(used_files), 5, NULL, (int (*)(void *)) zend_open_file_dtor_wrapper, 0);
+ zend_hash_init(&CG(used_files), 5, NULL, (void (*)(void *)) zend_open_file_dtor_wrapper, 0);
}
View
@@ -362,12 +362,12 @@ ZEND_API void zend_close_file_handle(zend_file_handle *file_handle CLS_DC);
ZEND_API void zend_open_file_dtor(zend_file_handle *fh);
END_EXTERN_C()
-ZEND_API int destroy_zend_function(zend_function *function);
-ZEND_API int destroy_zend_class(zend_class_entry *ce);
+ZEND_API void destroy_zend_function(zend_function *function);
+ZEND_API void 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
+#define ZEND_FUNCTION_DTOR (void (*)(void *)) destroy_zend_function
+#define ZEND_CLASS_DTOR (void (*)(void *)) destroy_zend_class
zend_op *get_next_op(zend_op_array *op_array CLS_DC);
void init_op(zend_op *op CLS_DC);
View
@@ -25,13 +25,12 @@
#include "zend_globals.h"
-int free_zend_constant(zend_constant *c)
+void free_zend_constant(zend_constant *c)
{
if (!(c->flags & CONST_PERSISTENT)) {
zval_dtor(&c->value);
}
free(c->name);
- return 1;
}
View
@@ -45,7 +45,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);
-int free_zend_constant(zend_constant *c);
+void free_zend_constant(zend_constant *c);
int zend_startup_constants(ELS_D);
int zend_shutdown_constants(ELS_D);
void zend_register_standard_constants(ELS_D);
@@ -59,6 +59,6 @@ ZEND_API void zend_register_constant(zend_constant *c ELS_DC);
void zend_copy_constants(HashTable *target, HashTable *sourc);
void copy_zend_constant(zend_constant *c);
-#define ZEND_CONSTANT_DTOR (int (*)(void *)) free_zend_constant
+#define ZEND_CONSTANT_DTOR (void (*)(void *)) free_zend_constant
#endif
View
@@ -206,7 +206,7 @@ ZEND_API inline void safe_free_zval_ptr(zval *p)
}
-ZEND_API int _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC)
+ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC)
{
#if DEBUG_ZEND>=2
printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, (*zval_ptr)->refcount, (*zval_ptr)->refcount-1);
@@ -216,7 +216,6 @@ ZEND_API int _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC)
zval_dtor(*zval_ptr);
safe_free_zval_ptr(*zval_ptr);
}
- return 1;
}
View
@@ -101,7 +101,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), int (*pDestructor) (void *pData),int persistent)
+ZEND_API int zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, int persistent)
{
uint i;
@@ -771,7 +771,6 @@ 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;
IS_CONSISTENT(ht);
@@ -783,19 +782,13 @@ ZEND_API void zend_hash_destroy(HashTable *ht)
p = p->pListNext;
if (!q->bIsPointer) {
if (ht->pDestructor) {
- delete_bucket = ht->pDestructor(q->pData);
- } else {
- delete_bucket = 1;
+ ht->pDestructor(q->pData);
}
- if (!q->pDataPtr && q->pData && delete_bucket) {
+ 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);
View
@@ -34,6 +34,11 @@
#define HASH_DEL_KEY 0
#define HASH_DEL_INDEX 1
+typedef int (*compare_func_t)(const void *, const void *);
+typedef void (*sort_func_t)(void *, size_t, register size_t, compare_func_t);
+typedef void (*dtor_func_t)(void *pDest);
+typedef ulong (*hash_func_t)(char *arKey, uint nKeyLength);
+
struct hashtable;
typedef struct bucket {
@@ -53,25 +58,22 @@ typedef struct hashtable {
uint nHashSizeIndex;
uint nNumOfElements;
ulong nNextFreeElement;
- ulong(*pHashFunction) (char *arKey, uint nKeyLength);
+ hash_func_t pHashFunction;
Bucket *pInternalPointer; /* Used for element traversal */
Bucket *pListHead;
Bucket *pListTail;
Bucket **arBuckets;
- int (*pDestructor) (void *pData);
+ dtor_func_t pDestructor;
unsigned char persistent;
#if ZEND_DEBUG
int inconsistent;
#endif
} HashTable;
-typedef int (*compare_func_t) (const void *, const void *);
-typedef void (*sort_func_t) (void *, size_t, register size_t, compare_func_t);
-
BEGIN_EXTERN_C()
/* startup/shutdown */
-ZEND_API int zend_hash_init(HashTable *ht, uint nSize, ulong(*pHashFunction) (char *arKey, uint nKeyLength), int (*pDestructor) (void *pData), int persistent);
+ZEND_API int zend_hash_init(HashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, int persistent);
ZEND_API void zend_hash_destroy(HashTable *ht);
ZEND_API void zend_hash_clean(HashTable *ht);
View
@@ -204,7 +204,7 @@ ZEND_API void *zend_fetch_resource(zval **passed_id, int default_id, char *resou
}
-int list_entry_destructor(void *ptr)
+void list_entry_destructor(void *ptr)
{
list_entry *le = (list_entry *) ptr;
list_destructors_entry *ld;
@@ -216,11 +216,10 @@ int list_entry_destructor(void *ptr)
} else {
zend_error(E_WARNING,"Unknown list entry type in request shutdown (%d)",le->type);
}
- return 1;
}
-int plist_entry_destructor(void *ptr)
+void plist_entry_destructor(void *ptr)
{
list_entry *le = (list_entry *) ptr;
list_destructors_entry *ld;
@@ -232,7 +231,6 @@ int plist_entry_destructor(void *ptr)
} else {
zend_error(E_WARNING,"Unknown persistent list entry type in module shutdown (%d)",le->type);
}
- return 1;
}
View
@@ -46,8 +46,8 @@ enum list_entry_type {
LE_DB=1000
};
-int list_entry_destructor(void *ptr);
-int plist_entry_destructor(void *ptr);
+void list_entry_destructor(void *ptr);
+void plist_entry_destructor(void *ptr);
int clean_module_resource_destructors(list_destructors_entry *ld, int *module_number);
int init_resource_list(ELS_D);
View
@@ -60,5 +60,5 @@ void module_destructor(zend_module_entry *module);
int module_registry_cleanup(zend_module_entry *module);
int module_registry_request_startup(zend_module_entry *module);
-#define ZEND_MODULE_DTOR (int (*)(void *)) module_destructor
+#define ZEND_MODULE_DTOR (void (*)(void *)) module_destructor
#endif
View
@@ -105,7 +105,7 @@ void init_op_array(zend_op_array *op_array, int initial_ops_size)
}
-ZEND_API int destroy_zend_function(zend_function *function)
+ZEND_API void destroy_zend_function(zend_function *function)
{
switch (function->type) {
case ZEND_USER_FUNCTION:
@@ -115,14 +115,13 @@ ZEND_API int destroy_zend_function(zend_function *function)
/* do nothing */
break;
}
- return 1;
}
-ZEND_API int destroy_zend_class(zend_class_entry *ce)
+ZEND_API void destroy_zend_class(zend_class_entry *ce)
{
if (--(*ce->refcount)>0) {
- return 1;
+ return;
}
switch (ce->type) {
case ZEND_USER_CLASS:
@@ -138,7 +137,6 @@ ZEND_API int destroy_zend_class(zend_class_entry *ce)
zend_hash_destroy(&ce->default_properties);
break;
}
- return 1;
}
View
@@ -52,10 +52,10 @@ ZEND_API inline void var_uninit(zval *var)
}
-ZEND_API int _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC)
+ZEND_API void _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC)
{
if (zvalue->type==IS_LONG) {
- return 1;
+ return;
}
switch(zvalue->type) {
case IS_STRING:
@@ -84,10 +84,9 @@ ZEND_API int _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC)
case IS_BOOL:
case IS_NULL:
default:
- return 1;
+ return;
break;
}
- return 1;
}
@@ -169,14 +168,14 @@ ZEND_API int _zval_copy_ctor_wrapper(zval *zvalue)
}
-ZEND_API int _zval_dtor_wrapper(zval *zvalue)
+ZEND_API void _zval_dtor_wrapper(zval *zvalue)
{
- return zval_dtor(zvalue);
+ zval_dtor(zvalue);
}
-ZEND_API int _zval_ptr_dtor_wrapper(zval **zval_ptr)
+ZEND_API void _zval_ptr_dtor_wrapper(zval **zval_ptr)
{
return zval_ptr_dtor(zval_ptr);
}
View
@@ -26,16 +26,16 @@ ZEND_API int zend_print_variable(zval *var);
BEGIN_EXTERN_C()
ZEND_API int _zval_copy_ctor(zval *zvalue ZEND_FILE_LINE_DC);
-ZEND_API int _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC);
-ZEND_API int _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
+ZEND_API void _zval_dtor(zval *zvalue ZEND_FILE_LINE_DC);
+ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC);
#define zval_copy_ctor(zvalue) _zval_copy_ctor((zvalue) ZEND_FILE_LINE_CC)
#define zval_dtor(zvalue) _zval_dtor((zvalue) ZEND_FILE_LINE_CC)
#define zval_ptr_dtor(zval_ptr) _zval_ptr_dtor((zval_ptr) ZEND_FILE_LINE_CC)
#if ZEND_DEBUG
ZEND_API int _zval_copy_ctor_wrapper(zval *zvalue);
-ZEND_API int _zval_dtor_wrapper(zval *zvalue);
-ZEND_API int _zval_ptr_dtor_wrapper(zval **zval_ptr);
+ZEND_API void _zval_dtor_wrapper(zval *zvalue);
+ZEND_API void _zval_ptr_dtor_wrapper(zval **zval_ptr);
#define zval_copy_ctor_wrapper _zval_copy_ctor_wrapper
#define zval_dtor_wrapper _zval_dtor_wrapper
#define zval_ptr_dtor_wrapper _zval_ptr_dtor_wrapper
@@ -51,8 +51,8 @@ END_EXTERN_C()
void zval_add_ref(zval **p);
void zval_del_ref(zval **p);
-#define ZVAL_DESTRUCTOR (int (*)(void *)) zval_dtor_wrapper
-#define ZVAL_PTR_DTOR (int (*)(void *)) zval_ptr_dtor_wrapper
+#define ZVAL_DESTRUCTOR (void (*)(void *)) zval_dtor_wrapper
+#define ZVAL_PTR_DTOR (void (*)(void *)) zval_ptr_dtor_wrapper
#define ZVAL_COPY_CTOR (void (*)(void *)) zval_copy_ctor_wrapper
ZEND_API void var_reset(zval *var);
View
@@ -86,10 +86,9 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
return r;
}
-static int _free_reg_cache(reg_cache *rc)
+static void _free_reg_cache(reg_cache *rc)
{
regfree(&rc->preg);
- return 1;
}
#undef regfree
@@ -99,7 +98,7 @@ static int _free_reg_cache(reg_cache *rc)
static void php_reg_init_globals(php_reg_globals *reg_globals)
{
- zend_hash_init(&reg_globals->ht_rc, 0, NULL, (int (*)(void *)) _free_reg_cache, 1);
+ zend_hash_init(&reg_globals->ht_rc, 0, NULL, (void (*)(void *)) _free_reg_cache, 1);
}
static PHP_MINIT_FUNCTION(regex)
View
@@ -60,14 +60,13 @@ static void php_pcre_free(void *ptr)
}
-static int _php_free_pcre_cache(void *data)
+static void _php_free_pcre_cache(void *data)
{
pcre_cache_entry *pce = (pcre_cache_entry *) data;
pefree(pce->re, 1);
#if HAVE_SETLOCALE
pefree((void*)pce->tables, 1);
#endif
- return 1;
}
Oops, something went wrong.

0 comments on commit 62114c1

Please sign in to comment.