]> granicus.if.org Git - php/commitdiff
- Hooray. This might actually work. (I hope)
authorAndi Gutmans <andi@php.net>
Sun, 3 Oct 1999 20:06:21 +0000 (20:06 +0000)
committerAndi Gutmans <andi@php.net>
Sun, 3 Oct 1999 20:06:21 +0000 (20:06 +0000)
Zend/zend_compile.h
Zend/zend_execute.c
Zend/zend_execute_API.c
Zend/zend_globals.h

index 1e17e34d3037ece970fae446b503c8285222106e..95ad06e4a3bae1f858910e009dab1435b096c852 100644 (file)
@@ -568,7 +568,21 @@ int zendlex(znode *zendlval CLS_DC);
 #define PZVAL_IS_REF(z)                ((z)->is_ref)
 
 #define PZVAL_LOCK(z)  ((z)->refcount++)
-#define PZVAL_UNLOCK(z)        ((z)->refcount--)
+#define PZVAL_UNLOCK(z)        { ((z)->refcount--);                                                    \
+                                                       if (!(z)->refcount) {                                           \
+                                                               EG(garbage)[EG(garbage_ptr)++] = (z);   \
+                                                               if (EG(garbage_ptr) == 4) {                             \
+                                                                       zval_dtor(EG(garbage)[0]);                      \
+                                                                       efree(EG(garbage)[0]);                          \
+                                                                       zval_dtor(EG(garbage)[1]);                      \
+                                                                       efree(EG(garbage)[1]);                          \
+                                                                       EG(garbage)[0] = EG(garbage)[2];        \
+                                                                       EG(garbage)[1] = EG(garbage)[3];        \
+                                                                       EG(garbage_ptr) -= 2;                           \
+                                                               }                                                                               \
+                                                       }                                                                                       \
+                                               }
+
 #define SELECTIVE_PZVAL_LOCK(pzv, pzn)         if (!((pzn)->u.EA.type & EXT_TYPE_UNUSED)) { PZVAL_LOCK(pzv); }
 
 #endif /* _COMPILE_H */
index c93f8e056ab0e4ce45a8f5ff91ce6196272cff05..9fda4a6485570dd5a60f5e306cc78b9a625fc914 100644 (file)
@@ -1508,7 +1508,6 @@ do_fcall_common:
                                                EG(opline_ptr) = &opline;
                                                EG(active_op_array) = op_array;
                                                EG(return_value)=original_return_value;
-                                               EG(destroying_function_symbol_table) = 1;
                                                if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) {
                                                        zend_hash_destroy(function_state.function_symbol_table);
                                                        efree(function_state.function_symbol_table);
@@ -1516,7 +1515,6 @@ do_fcall_common:
                                                        *(++EG(symtable_cache_ptr)) = function_state.function_symbol_table;
                                                        zend_hash_clean(*EG(symtable_cache_ptr));
                                                }
-                                               EG(destroying_function_symbol_table) = 0;
                                                EG(active_symbol_table) = calling_symbol_table;
                                        } else { /* ZEND_OVERLOADED_FUNCTION */
                                                call_overloaded_function(opline->extended_value, &Ts[opline->result.u.var].tmp_var, &EG(regular_list), &EG(persistent_list) ELS_CC);
index c9f0abebeecc03a78bb9cc0457b91a4a3099804a..4be3f58808f06afa0aea8e63c051a97739a9556f 100644 (file)
@@ -89,7 +89,6 @@ void init_executor(CLS_D ELS_DC)
        EG(error_zval).refcount = 1;
        EG(error_zval).is_ref=0;
        EG(error_zval_ptr)=&EG(error_zval);
-       EG(destroying_function_symbol_table) = 0;
        zend_ptr_stack_init(&EG(arg_types_stack));
        zend_stack_init(&EG(overloaded_objects_stack));
 /* destroys stack frame, therefore makes core dumps worthless */
@@ -115,6 +114,7 @@ void init_executor(CLS_D ELS_DC)
 
        zend_llist_apply(&zend_extensions, (void (*)(void *)) zend_extension_activator);
        EG(opline_ptr) = NULL;
+       EG(garbage_ptr) = 0;
 }
 
 
@@ -144,6 +144,10 @@ void shutdown_executor(ELS_D)
 #if ZEND_DEBUG
        signal(SIGSEGV, original_sigsegv_handler);
 #endif
+       while (EG(garbage_ptr)--) {
+               zval_dtor(EG(garbage)[EG(garbage_ptr)]);
+               efree(EG(garbage)[EG(garbage_ptr)]);
+       }
 }
 
 
index 5e9d1f4d81f0a66dce453005f9389e71a39cf193..ea740e107d5e3d753619669fbeb0dfb42145caf2 100644 (file)
@@ -138,7 +138,6 @@ struct _zend_executor_globals {
        HashTable *zend_constants;      /* constants table */
 
        long precision;
-       zend_bool destroying_function_symbol_table;
 
        /* for extended information support */
        zend_bool no_extensions;
@@ -151,6 +150,9 @@ struct _zend_executor_globals {
        int (*unary_op)(zval *result, zval *op1);
        int (*binary_op)(zval *result, zval *op1, zval *op2);
 
+       zval *garbage[4];
+       int garbage_ptr;
+
        void *reserved[ZEND_MAX_RESERVED_RESOURCES];
 #if SUPPORT_INTERACTIVE
        int interactive;