- Make class_entry->refcount be part of the structure and not allocated.
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);
}
char *name;
uint name_length;
struct _zend_class_entry *parent;
- int *refcount;
+ int refcount;
zend_bool constants_updated;
HashTable function_table;
}
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;
}
}
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);
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);
}
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;
}
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);
}
} else {
ce = *pce;
}
- (*ce->refcount)++;
+ ce->refcount++;
/* Obtain parent class */
parent_name_length = class_name - opline->op2.u.constant.value.str.val - 1;
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;
}
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);
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);
{
zend_class_entry *ce = *pce;
- if (--(*ce->refcount)>0) {
+ if (--ce->refcount > 0) {
return;
}
switch (ce->type) {
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);
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);
void zend_class_add_ref(zend_class_entry **ce)
{
- (*(*ce)->refcount)++;
+ (*ce)->refcount++;
}
/* 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;
}