]> granicus.if.org Git - php/commitdiff
Step 1 in nuking the garbage collector:
authorZeev Suraski <zeev@php.net>
Fri, 9 Jul 1999 17:36:12 +0000 (17:36 +0000)
committerZeev Suraski <zeev@php.net>
Fri, 9 Jul 1999 17:36:12 +0000 (17:36 +0000)
- Change the hash destructor to return int

ext/ereg/ereg.c
ext/pcre/php_pcre.c
ext/standard/basic_functions.c
ext/standard/reg.c
main/configuration-parser.y

index b01f659bdd148aa8bfc8e1877b2311ab2126ae75..7c8fac5758c905534341089bac85d6a0899bacee 100644 (file)
@@ -98,9 +98,10 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
        return r;
 }
 
-static void _free_reg_cache(reg_cache *rc) 
+static int _free_reg_cache(reg_cache *rc) 
 {
        regfree(&rc->preg);
+       return 1;
 }
 
 #define regfree(a);
@@ -108,7 +109,7 @@ static void _free_reg_cache(reg_cache *rc)
        
 static void php_reg_init_globals(php_reg_globals *reg_globals) 
 {
-       _php3_hash_init(&reg_globals->ht_rc, 0, NULL, (void (*)(void *)) _free_reg_cache, 1);
+       _php3_hash_init(&reg_globals->ht_rc, 0, NULL, (int (*)(void *)) _free_reg_cache, 1);
 }
 
 static int php_minit_regex(INIT_FUNC_ARGS)
index 5b838ec05598afe55d840c8ecd4b821e595bd5d2..ed1245cf021ed537cb5c7414bc2eec25c06a1424 100644 (file)
@@ -84,10 +84,11 @@ static void php_pcre_free(void *ptr)
 }
 
 
-static void _php_free_pcre_cache(void *data)
+static int _php_free_pcre_cache(void *data)
 {
        pcre_cache_entry *pce = (pcre_cache_entry *) data;
        pefree(pce->re, 1);
+       return 1;
 }
 
 
index d182714053e1a5496501c49694ea18817fde43f0..6333f7b4d157c05ef9e44d64e3f3558b03309ebc 100644 (file)
@@ -64,7 +64,7 @@ static pval *user_compare_func_name;
 static HashTable *user_shutdown_function_names;
 
 /* some prototypes for local functions */
-void user_shutdown_function_dtor(pval *user_shutdown_function_name);
+int user_shutdown_function_dtor(pval *user_shutdown_function_name);
 int user_shutdown_function_executor(pval *user_shutdown_function_name);
 void php3_call_shutdown_functions(void);
 
@@ -332,7 +332,7 @@ php3_module_entry basic_functions_module = {
 #ifdef HAVE_PUTENV
 static HashTable putenv_ht;
 
-static void _php3_putenv_destructor(putenv_entry *pe)
+static int _php3_putenv_destructor(putenv_entry *pe)
 {
        if (pe->previous_value) {
                putenv(pe->previous_value);
@@ -352,6 +352,7 @@ static void _php3_putenv_destructor(putenv_entry *pe)
        }
        efree(pe->putenv_string);
        efree(pe->key);
+       return 1;
 }
 #endif
 
@@ -395,7 +396,7 @@ int php3_rinit_basic(INIT_FUNC_ARGS)
 {
        strtok_string = NULL;
 #ifdef HAVE_PUTENV
-       if (_php3_hash_init(&putenv_ht, 1, NULL, (void (*)(void *)) _php3_putenv_destructor, 0) == FAILURE) {
+       if (_php3_hash_init(&putenv_ht, 1, NULL, (int (*)(void *)) _php3_putenv_destructor, 0) == FAILURE) {
                return FAILURE;
        }
 #endif
@@ -1776,7 +1777,7 @@ PHP_FUNCTION(call_user_method)
 }
 
 
-void user_shutdown_function_dtor(pval *user_shutdown_function_name)
+int user_shutdown_function_dtor(pval *user_shutdown_function_name)
 {
        pval retval;
        CLS_FETCH();
@@ -1785,6 +1786,7 @@ void user_shutdown_function_dtor(pval *user_shutdown_function_name)
                pval_destructor(&retval);
        }
        pval_destructor(user_shutdown_function_name);
+       return 1;
 }
 
 
@@ -1809,7 +1811,7 @@ PHP_FUNCTION(register_shutdown_function)
        convert_to_string(arg);
        if (!user_shutdown_function_names) {
                user_shutdown_function_names = (HashTable *) emalloc(sizeof(HashTable));
-               _php3_hash_init(user_shutdown_function_names, 0, NULL, (void (*)(void *))user_shutdown_function_dtor, 0);
+               _php3_hash_init(user_shutdown_function_names, 0, NULL, (int (*)(void *))user_shutdown_function_dtor, 0);
        }
        
        shutdown_function_name = *arg;
index b01f659bdd148aa8bfc8e1877b2311ab2126ae75..7c8fac5758c905534341089bac85d6a0899bacee 100644 (file)
@@ -98,9 +98,10 @@ static int _php_regcomp(regex_t *preg, const char *pattern, int cflags)
        return r;
 }
 
-static void _free_reg_cache(reg_cache *rc) 
+static int _free_reg_cache(reg_cache *rc) 
 {
        regfree(&rc->preg);
+       return 1;
 }
 
 #define regfree(a);
@@ -108,7 +109,7 @@ static void _free_reg_cache(reg_cache *rc)
        
 static void php_reg_init_globals(php_reg_globals *reg_globals) 
 {
-       _php3_hash_init(&reg_globals->ht_rc, 0, NULL, (void (*)(void *)) _free_reg_cache, 1);
+       _php3_hash_init(&reg_globals->ht_rc, 0, NULL, (int (*)(void *)) _free_reg_cache, 1);
 }
 
 static int php_minit_regex(INIT_FUNC_ARGS)
index fecfc323df1990a23f7fff4dbc7653c7d9d3d00d..c2c9102a5bf813dc2336c4959c082bcddc5c1b51 100644 (file)
@@ -138,20 +138,22 @@ static void yyerror(char *str)
 }
 
 
-static void pvalue_config_destructor(pval *pvalue)
+static int pvalue_config_destructor(pval *pvalue)
 {
        if (pvalue->type == IS_STRING && pvalue->value.str.val != empty_string) {
                free(pvalue->value.str.val);
        }
+       return 1;
 }
 
 
-static void pvalue_browscap_destructor(pval *pvalue)
+static int pvalue_browscap_destructor(pval *pvalue)
 {
        if (pvalue->type == IS_OBJECT || pvalue->type == IS_ARRAY) {
                _php3_hash_destroy(pvalue->value.ht);
                free(pvalue->value.ht);
        }
+       return 1;
 }
 
 
@@ -159,7 +161,7 @@ int php3_init_config(void)
 {
        PLS_FETCH();
 
-       if (_php3_hash_init(&configuration_hash, 0, NULL, (void (*)(void *))pvalue_config_destructor, 1)==FAILURE) {
+       if (_php3_hash_init(&configuration_hash, 0, NULL, (int (*)(void *))pvalue_config_destructor, 1)==FAILURE) {
                return FAILURE;
        }
 
@@ -258,7 +260,7 @@ int php3_minit_browscap(INIT_FUNC_ARGS)
        char *browscap = INI_STR("browscap");
 
        if (browscap) {
-               if (_php3_hash_init(&browser_hash, 0, NULL, (void (*)(void *))pvalue_browscap_destructor, 1)==FAILURE) {
+               if (_php3_hash_init(&browser_hash, 0, NULL, (int (*)(void *))pvalue_browscap_destructor, 1)==FAILURE) {
                        return FAILURE;
                }
 
@@ -411,7 +413,7 @@ statement:
 
                                /*printf("'%s' (%d)\n",$1.value.str.val,$1.value.str.len+1);*/
                                tmp.value.ht = (HashTable *) malloc(sizeof(HashTable));
-                               _php3_hash_init(tmp.value.ht, 0, NULL, (void (*)(void *))pvalue_config_destructor, 1);
+                               _php3_hash_init(tmp.value.ht, 0, NULL, (int (*)(void *))pvalue_config_destructor, 1);
                                tmp.type = IS_OBJECT;
                                _php3_hash_update(active__php3_hash_table, $1.value.str.val, $1.value.str.len+1, (void *) &tmp, sizeof(pval), (void **) &current_section);
                                tmp.value.str.val = php3_strndup($1.value.str.val,$1.value.str.len);