]> granicus.if.org Git - php/commitdiff
- Another couple of indirection fixes.
authorAndi Gutmans <andi@php.net>
Tue, 12 Mar 2002 19:22:29 +0000 (19:22 +0000)
committerAndi Gutmans <andi@php.net>
Tue, 12 Mar 2002 19:22:29 +0000 (19:22 +0000)
- Make class_entry->refcount be part of the structure and not allocated.

Zend/zend.c
Zend/zend.h
Zend/zend_API.c
Zend/zend_compile.c
Zend/zend_opcode.c
Zend/zend_operators.c

index 713bdfd5e8b0346196e5ff6d525f8898b8228c34..6c6815bd3f348bccb36c640b3e2039bcc92397aa 100644 (file)
@@ -265,8 +265,7 @@ static void register_standard_class(void)
        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_standard_class_def->refcount = (int *) malloc(sizeof(int));
-       *zend_standard_class_def->refcount = 1;
+       zend_standard_class_def->refcount = 1;
        zend_hash_add(GLOBAL_CLASS_TABLE, "stdclass", sizeof("stdclass"), &zend_standard_class_def, sizeof(zend_class_entry *), NULL);
 }
 
index e7b0704b0a7c7f92ab976e8fe2c6e3569307c419..3cb1eb58f4a41bc7f5ffc6bfbd41c21cff0aca75 100644 (file)
@@ -265,7 +265,7 @@ struct _zend_class_entry {
        char *name;
        uint name_length;
        struct _zend_class_entry *parent; 
-       int *refcount;
+       int refcount;
        zend_bool constants_updated;
 
        HashTable function_table;
index d85eafddb52787d5689a5084011d506edf184334..26ee2ce77d6406af2aafe0bc58179209a6f813fb 100644 (file)
@@ -212,10 +212,7 @@ static int zend_check_class(zval *obj, zend_class_entry *expected_ce)
        }
        
        for (ce = Z_OBJCE_P(obj); ce != NULL; ce = ce->parent) {
-               /*
-                * C'est une UGLY HACK.
-                */
-               if (ce->refcount == expected_ce->refcount) {
+               if (ce == expected_ce) {
                        return 1;
                }
        }
@@ -1228,8 +1225,7 @@ ZEND_API zend_class_entry *zend_register_internal_class(zend_class_entry *orig_c
 
        class_entry->type = ZEND_INTERNAL_CLASS;
        class_entry->parent = NULL;
-       class_entry->refcount = (int *) malloc(sizeof(int));
-       *class_entry->refcount = 1;
+       class_entry->refcount = 1;
        class_entry->constants_updated = 0;
        zend_hash_init(&class_entry->default_properties, 0, NULL, ZVAL_PTR_DTOR, 1);
        zend_hash_init(&class_entry->private_properties, 0, NULL, ZVAL_PTR_DTOR, 1);
index d1fc686b6ea4fd509370b76b184cd950857cc907..235fc5cd0d0d6c31e1c9b81a9945cb4560f8782d 100644 (file)
@@ -1516,8 +1516,7 @@ static void create_class(HashTable *class_table, char *name, int name_length, ze
        new_class_entry->type = ZEND_USER_CLASS;
        new_class_entry->name = estrndup(name, name_length);
        new_class_entry->name_length = name_length;
-       new_class_entry->refcount = (int *) emalloc(sizeof(int));
-       *new_class_entry->refcount = 1;
+       new_class_entry->refcount = 1;
        new_class_entry->constants_updated = 0;
 
        zend_str_tolower(new_class_entry->name, new_class_entry->name_length);
@@ -1578,9 +1577,9 @@ static int create_nested_class(HashTable *class_table, char *path, zend_class_en
                }
                last = cur;
        }
-       (*new_ce->refcount)++;
+       new_ce->refcount++;
        if (zend_hash_add(&ce->class_table, last, strlen(last)+1, &new_ce, sizeof(zend_class_entry *), NULL) == FAILURE) {
-               (*new_ce->refcount)--;
+               new_ce->refcount--;
                zend_error(E_ERROR, "Cannot redeclare class %s", last);
                return FAILURE;
        }
@@ -1628,9 +1627,9 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
                                if (strchr(opline->op2.u.constant.value.str.val, ':')) {
                                        return create_nested_class(class_table, opline->op2.u.constant.value.str.val, ce);
                                }
-                               (*ce->refcount)++;
+                               ce->refcount++;
                                if (zend_hash_add(class_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, &ce, sizeof(zend_class_entry *), NULL)==FAILURE) {
-                                       (*ce->refcount)--;
+                                       ce->refcount--;
                                        if (!compile_time) {
                                                zend_error(E_ERROR, "Cannot redeclare class %s", opline->op2.u.constant.value.str.val);
                                        }
@@ -1662,7 +1661,7 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
                                } else {
                                        ce = *pce;
                                }
-                               (*ce->refcount)++;
+                               ce->refcount++;
 
                                /* Obtain parent class */
                                parent_name_length = class_name - opline->op2.u.constant.value.str.val - 1;
@@ -1671,7 +1670,7 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
                                        if (!compile_time) {
                                                zend_error(E_ERROR, "Class %s:  Cannot inherit from undefined class %s", class_name, parent_name);
                                        }
-                                       (*ce->refcount)--;
+                                       ce->refcount--;
                                        efree(parent_name);
                                        return FAILURE;
                                }
@@ -1684,7 +1683,7 @@ ZEND_API int do_bind_function_or_class(zend_op *opline, HashTable *function_tabl
                                        if (!compile_time) {
                                                zend_error(E_ERROR, "Cannot redeclare class %s", opline->op2.u.constant.value.str.val);
                                        }
-                                       (*ce->refcount)--;
+                                       ce->refcount--;
                                        zend_hash_destroy(&ce->function_table);
                                        zend_hash_destroy(&ce->default_properties);
                                        zend_hash_destroy(&ce->private_properties);
@@ -2015,8 +2014,7 @@ void zend_do_begin_class_declaration(znode *class_token, znode *class_name, znod
        new_class_entry->type = ZEND_USER_CLASS;
        new_class_entry->name = class_name->u.constant.value.str.val;
        new_class_entry->name_length = class_name->u.constant.value.str.len;
-       new_class_entry->refcount = (int *) emalloc(sizeof(int));
-       *new_class_entry->refcount = 1;
+       new_class_entry->refcount = 1;
        new_class_entry->constants_updated = 0;
        
        zend_str_tolower(new_class_entry->name, new_class_entry->name_length);
index 9de9c78a4fb27c2cd0c8b9cce471038008692418..ed10615c83a8df5d11e1a264f19a5a4b858ff7bc 100644 (file)
@@ -110,7 +110,7 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce)
 {
        zend_class_entry *ce = *pce;
        
-       if (--(*ce->refcount)>0) {
+       if (--ce->refcount > 0) {
                return;
        }
        switch (ce->type) {
@@ -119,7 +119,6 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce)
                        zend_hash_destroy(&ce->private_properties);
                        zend_hash_destroy(ce->static_members);
                        efree(ce->name);
-                       efree(ce->refcount);
                        zend_hash_destroy(&ce->function_table);
                        FREE_HASHTABLE(ce->static_members);
                        zend_hash_destroy(&ce->constants_table);
@@ -131,7 +130,6 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce)
                        zend_hash_destroy(&ce->private_properties);
                        zend_hash_destroy(ce->static_members);
                        free(ce->name);
-                       free(ce->refcount);
                        zend_hash_destroy(&ce->function_table);
                        free(ce->static_members);
                        zend_hash_destroy(&ce->constants_table);
@@ -144,7 +142,7 @@ ZEND_API void destroy_zend_class(zend_class_entry **pce)
 
 void zend_class_add_ref(zend_class_entry **ce)
 {
-       (*(*ce)->refcount)++;
+       (*ce)->refcount++;
 }
 
 
index 0695b4606efe65ed8f8ccca0711dfa286989b169..a74be6b6a33744e301454e7cdeec514b0d4ccab3 100644 (file)
@@ -549,7 +549,7 @@ ZEND_API void convert_to_object(zval *op)
                                /* OBJECTS_OPTIMIZE */
                                TSRMLS_FETCH();
 
-                               object_and_properties_init(op, &zend_standard_class_def, op->value.ht);
+                               object_and_properties_init(op, zend_standard_class_def, op->value.ht);
                                return;
                                break;
                        }