cvs: ZendEngine2 / zend.c zend.h zend_API.c zend_compile.c zend_opcode.c zend_operators.c
| From: | Andi Gutmans | Date: | Tue, 12 Mar 2002 19:22:30 +0000 |
| Subject: | cvs: ZendEngine2 / zend.c zend.h zend_API.c zend_compile.c zend_opcode.c zend_operators.c | ||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-14@lists.php.net to get a copy of this message | ||
andi Tue Mar 12 14:22:30 2002 EDT
Modified files:
/ZendEngine2 zend.c zend.h zend_API.c zend_compile.c zend_opcode.c
zend_operators.c
Log:
- Another couple of indirection fixes.
- Make class_entry->refcount be part of the structure and not allocated.
Index: ZendEngine2/zend.c
diff -u ZendEngine2/zend.c:1.164 ZendEngine2/zend.c:1.165
--- ZendEngine2/zend.c:1.164 Tue Mar 12 05:08:46 2002
+++ ZendEngine2/zend.c Tue Mar 12 14:22:29 2002
@@ -265,8 +265,7 @@
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: ZendEngine2/zend.h
diff -u ZendEngine2/zend.h:1.162 ZendEngine2/zend.h:1.163
--- ZendEngine2/zend.h:1.162 Tue Mar 12 05:08:46 2002
+++ ZendEngine2/zend.h Tue Mar 12 14:22:29 2002
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend.h,v 1.162 2002/03/12 10:08:46 stas Exp $ */
+/* $Id: zend.h,v 1.163 2002/03/12 19:22:29 andi Exp $ */
#ifndef ZEND_H
#define ZEND_H
@@ -265,7 +265,7 @@
char *name;
uint name_length;
struct _zend_class_entry *parent;
- int *refcount;
+ int refcount;
zend_bool constants_updated;
HashTable function_table;
Index: ZendEngine2/zend_API.c
diff -u ZendEngine2/zend_API.c:1.123 ZendEngine2/zend_API.c:1.124
--- ZendEngine2/zend_API.c:1.123 Tue Mar 12 06:28:30 2002
+++ ZendEngine2/zend_API.c Tue Mar 12 14:22:29 2002
@@ -212,10 +212,7 @@
}
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 @@
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: ZendEngine2/zend_compile.c
diff -u ZendEngine2/zend_compile.c:1.277 ZendEngine2/zend_compile.c:1.278
--- ZendEngine2/zend_compile.c:1.277 Tue Mar 12 13:53:27 2002
+++ ZendEngine2/zend_compile.c Tue Mar 12 14:22:29 2002
@@ -1516,8 +1516,7 @@
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 @@
}
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 @@
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 @@
} 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 @@
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 @@
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 @@
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: ZendEngine2/zend_opcode.c
diff -u ZendEngine2/zend_opcode.c:1.68 ZendEngine2/zend_opcode.c:1.69
--- ZendEngine2/zend_opcode.c:1.68 Tue Mar 12 13:53:27 2002
+++ ZendEngine2/zend_opcode.c Tue Mar 12 14:22:29 2002
@@ -110,7 +110,7 @@
{
zend_class_entry *ce = *pce;
- if (--(*ce->refcount)>0) {
+ if (--ce->refcount > 0) {
return;
}
switch (ce->type) {
@@ -119,7 +119,6 @@
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_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 @@
void zend_class_add_ref(zend_class_entry **ce)
{
- (*(*ce)->refcount)++;
+ (*ce)->refcount++;
}
Index: ZendEngine2/zend_operators.c
diff -u ZendEngine2/zend_operators.c:1.119 ZendEngine2/zend_operators.c:1.120
--- ZendEngine2/zend_operators.c:1.119 Thu Feb 7 09:08:43 2002
+++ ZendEngine2/zend_operators.c Tue Mar 12 14:22:29 2002
@@ -549,7 +549,7 @@
/* 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;
}