Now we destroy objects it two steps. At first - object properties of all objects and only then the objects their selves.
if (object &&
(!EG(objects_store).object_buckets ||
- !IS_VALID(EG(objects_store).object_buckets[object->handle]))) {
+ !IS_OBJ_VALID(EG(objects_store).object_buckets[object->handle]))) {
return 0;
}
} else if (Z_TYPE_P(obj) == IS_OBJECT) {
if (!EG(objects_store).object_buckets ||
- !IS_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(obj)])) {
+ !IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(obj)])) {
return 0;
}
if (Z_TYPE(closure->this_ptr) != IS_UNDEF) {
zval_ptr_dtor(&closure->this_ptr);
}
-
- GC_REMOVE_FROM_BUFFER(closure);
- efree(closure);
}
/* }}} */
EX(object) = fci->object = fci_cache->object;
if (fci->object &&
(!EG(objects_store).object_buckets ||
- !IS_VALID(EG(objects_store).object_buckets[fci->object->handle]))) {
+ !IS_OBJ_VALID(EG(objects_store).object_buckets[fci->object->handle]))) {
return FAILURE;
}
zend_object_get_gc_t get_gc;
zend_object *obj = (zend_object*)ref;
- if (EXPECTED(IS_VALID(EG(objects_store).object_buckets[obj->handle]) &&
+ if (EXPECTED(IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
(get_gc = obj->handlers->get_gc) != NULL)) {
int i, n;
zval *table;
zend_object_get_gc_t get_gc;
zend_object *obj = (zend_object*)ref;
- if (EXPECTED(IS_VALID(EG(objects_store).object_buckets[obj->handle]) &&
+ if (EXPECTED(IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
(get_gc = obj->handlers->get_gc) != NULL)) {
int i, n;
zval *table;
zend_object_get_gc_t get_gc;
zend_object *obj = (zend_object*)ref;
- if (EXPECTED(IS_VALID(EG(objects_store).object_buckets[obj->handle]) &&
+ if (EXPECTED(IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
(get_gc = obj->handlers->get_gc) != NULL)) {
int i, n;
zval *table;
/* PURPLE instead of BLACK to prevent buffering in nested gc calls */
//??? GC_SET_PURPLE(GC_INFO(obj));
- if (EXPECTED(IS_VALID(EG(objects_store).object_buckets[obj->handle]) &&
+ if (EXPECTED(IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
(get_gc = obj->handlers->get_gc) != NULL)) {
int i, n;
zval *table;
zend_object *obj = (zend_object*)p;
if (EG(objects_store).object_buckets &&
- obj->handlers->dtor_obj &&
- IS_VALID(EG(objects_store).object_buckets[obj->handle]) &&
+ IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
!(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
- GC_REFCOUNT(obj)++;
- obj->handlers->dtor_obj(obj TSRMLS_CC);
- GC_REFCOUNT(obj)--;
+ if (obj->handlers->dtor_obj) {
+ GC_REFCOUNT(obj)++;
+ obj->handlers->dtor_obj(obj TSRMLS_CC);
+ GC_REFCOUNT(obj)--;
+ }
}
}
current = GC_G(next_to_free);
zend_object *obj = (zend_object*)p;
if (EG(objects_store).object_buckets &&
- IS_VALID(EG(objects_store).object_buckets[obj->handle])) {
- GC_TYPE(obj) = IS_NULL;
- zend_objects_store_free(obj TSRMLS_CC);
+ IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
+ !(GC_FLAGS(obj) & IS_OBJ_FREE_CALLED)) {
+
+ GC_FLAGS(obj) |= IS_OBJ_FREE_CALLED;
+ if (obj->handlers->free_obj) {
+ GC_REFCOUNT(obj)++;
+ obj->handlers->free_obj(obj TSRMLS_CC);
+ GC_REFCOUNT(obj)--;
+ }
}
} else if (GC_TYPE(p) == IS_ARRAY) {
zend_array *arr = (zend_array*)p;
GC_TYPE(arr) = IS_NULL;
zend_hash_destroy(&arr->ht);
- GC_REMOVE_FROM_BUFFER(arr);
- efree(arr);
+ }
+ current = GC_G(next_to_free);
+ }
+
+ /* Free objects */
+ current = GC_G(to_free).next;
+ while (current != &GC_G(to_free)) {
+ p = current->ref;
+ GC_G(next_to_free) = current->next;
+ if (GC_TYPE(p) == IS_OBJECT) {
+ zend_object *obj = (zend_object*)p;
+
+ if (EG(objects_store).object_buckets &&
+ IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle])) {
+
+ zend_objects_store_free(obj TSRMLS_CC);
+ }
+ } else {
+ GC_REMOVE_FROM_BUFFER(p);
+ efree(p);
}
current = GC_G(next_to_free);
}
zend_object_std_dtor(&generator->std TSRMLS_CC);
- if (generator->iterator.std.handle) {
- zend_iterator_dtor(&generator->iterator TSRMLS_CC);
+ if (generator->iterator) {
+ zend_iterator_dtor(generator->iterator TSRMLS_CC);
}
-
- GC_REMOVE_FROM_BUFFER(generator);
- efree(generator);
}
/* }}} */
static void zend_generator_iterator_dtor(zend_object_iterator *iterator TSRMLS_DC) /* {{{ */
{
+ zend_generator *generator = (zend_generator*)Z_OBJ(iterator->data);
zval_ptr_dtor(&iterator->data);
+ generator->iterator = NULL;
}
/* }}} */
return NULL;
}
- iterator = &generator->iterator;
+ iterator = generator->iterator = emalloc(sizeof(zend_object_iterator));
zend_iterator_init(iterator TSRMLS_CC);
typedef struct _zend_generator {
zend_object std;
- zend_object_iterator iterator;
+ zend_object_iterator *iterator;
/* The suspended execution context. */
zend_execute_data *execute_data;
zend_user_it_invalidate_current(_iter TSRMLS_CC);
zval_ptr_dtor(object);
- efree(iter);
}
/* }}} */
static void iter_wrapper_dtor(zend_object *object TSRMLS_DC);
static zend_object_handlers iterator_object_handlers = {
+ 0,
iter_wrapper_dtor,
NULL,
NULL,
/* }}} */
ZEND_API zend_object_handlers std_object_handlers = {
- zend_object_free, /* free_obj */
+ 0, /* offset */
+
+ zend_object_std_dtor, /* free_obj */
zend_objects_destroy_object, /* dtor_obj */
zend_objects_clone_obj, /* clone_obj */
typedef int (*zend_object_do_operation_t)(zend_uchar opcode, zval *result, zval *op1, zval *op2 TSRMLS_DC);
struct _zend_object_handlers {
+ /* offset of real object header (usually zero) */
+ int offset;
/* general object functions */
zend_object_free_obj_t free_obj;
zend_object_dtor_obj_t dtor_obj;
}
}
-ZEND_API void zend_object_free(zend_object *object TSRMLS_DC)
-{
- zend_object_std_dtor(object TSRMLS_CC);
- GC_REMOVE_FROM_BUFFER(object);
- efree(object);
-}
-
ZEND_API zend_object *zend_objects_new(zend_class_entry *ce TSRMLS_DC)
{
zend_object *object = emalloc(sizeof(zend_object) + sizeof(zval) * (ce->default_properties_count - 1));
ZEND_API void zend_objects_destroy_object(zend_object *object TSRMLS_DC);
ZEND_API void zend_objects_clone_members(zend_object *new_object, zend_object *old_object TSRMLS_DC);
ZEND_API zend_object *zend_objects_clone_obj(zval *object TSRMLS_DC);
-ZEND_API void zend_object_free(zend_object *object TSRMLS_DC);
END_EXTERN_C()
#endif /* ZEND_OBJECTS_H */
ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects TSRMLS_DC)
{
- zend_uint i = 1;
+ zend_uint i;
for (i = 1; i < objects->top ; i++) {
zend_object *obj = objects->object_buckets[i];
- if (IS_VALID(obj)) {
+ if (IS_OBJ_VALID(obj)) {
if (!(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
GC_REFCOUNT(obj)++;
for (i = 1; i < objects->top ; i++) {
zend_object *obj = objects->object_buckets[i];
- if (IS_VALID(obj)) {
+ if (IS_OBJ_VALID(obj)) {
GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
}
}
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC)
{
- zend_uint i = 1;
+ zend_uint i;
+ /* Free object properties but don't free object their selves */
for (i = 1; i < objects->top ; i++) {
zend_object *obj = objects->object_buckets[i];
- if (IS_VALID(obj)) {
- objects->object_buckets[i] = SET_INVALID(obj);
- if (obj->handlers->free_obj) {
- obj->handlers->free_obj(obj TSRMLS_CC);
+ if (IS_OBJ_VALID(obj)) {
+ if (!(GC_FLAGS(obj) & IS_OBJ_FREE_CALLED)) {
+ GC_FLAGS(obj) |= IS_OBJ_FREE_CALLED;
+ if (obj->handlers->free_obj) {
+ GC_REFCOUNT(obj)++;
+ obj->handlers->free_obj(obj TSRMLS_CC);
+ GC_REFCOUNT(obj)--;
+ }
}
+ }
+ }
+
+ /* Now free objects theirselves */
+ for (i = 1; i < objects->top ; i++) {
+ zend_object *obj = objects->object_buckets[i];
+
+ if (IS_OBJ_VALID(obj)) {
/* Not adding to free list as we are shutting down anyway */
+ void *ptr = ((char*)obj) - obj->handlers->offset;
+ GC_REMOVE_FROM_BUFFER(obj);
+ efree(ptr);
}
}
}
if (EG(objects_store).free_list_head != -1) {
handle = EG(objects_store).free_list_head;
- EG(objects_store).free_list_head = GET_BUCKET_NUMBER(EG(objects_store).object_buckets[handle]);
+ EG(objects_store).free_list_head = GET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[handle]);
} else {
if (EG(objects_store).top == EG(objects_store).size) {
EG(objects_store).size <<= 1;
}
#define ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(handle) \
- SET_BUCKET_NUMBER(EG(objects_store).object_buckets[handle], EG(objects_store).free_list_head); \
+ SET_OBJ_BUCKET_NUMBER(EG(objects_store).object_buckets[handle], EG(objects_store).free_list_head); \
EG(objects_store).free_list_head = handle;
ZEND_API void zend_objects_store_free(zend_object *object TSRMLS_DC) /* {{{ */
{
- int handle = object->handle;
+ zend_uint handle = object->handle;
+ void *ptr = ((char*)object) - object->handlers->offset;
- EG(objects_store).object_buckets[handle] = SET_INVALID(object);
- if (object->handlers->free_obj) {
- object->handlers->free_obj(object TSRMLS_CC);
- }
+ GC_REMOVE_FROM_BUFFER(object);
+ efree(ptr);
ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(handle);
}
/* }}} */
when the refcount reaches 0 a second time
*/
if (EG(objects_store).object_buckets &&
- IS_VALID(EG(objects_store).object_buckets[object->handle])) {
+ IS_OBJ_VALID(EG(objects_store).object_buckets[object->handle])) {
if (GC_REFCOUNT(object) == 0) {
int failure = 0;
if (GC_REFCOUNT(object) == 0) {
zend_uint handle = object->handle;
-
- EG(objects_store).object_buckets[handle] = SET_INVALID(object);
- if (object->handlers->free_obj) {
- zend_try {
- object->handlers->free_obj(object TSRMLS_CC);
- } zend_catch {
- failure = 1;
- } zend_end_try();
+ void *ptr;
+
+ EG(objects_store).object_buckets[handle] = SET_OBJ_INVALID(object);
+ if (!(GC_FLAGS(object) & IS_OBJ_FREE_CALLED)) {
+ GC_FLAGS(object) |= IS_OBJ_FREE_CALLED;
+ if (object->handlers->free_obj) {
+ zend_try {
+ GC_REFCOUNT(object)++;
+ object->handlers->free_obj(object TSRMLS_CC);
+ GC_REFCOUNT(object)++;
+ } zend_catch {
+ failure = 1;
+ } zend_end_try();
+ }
}
+ ptr = ((char*)object) - object->handlers->offset;
+ GC_REMOVE_FROM_BUFFER(object);
+ efree(ptr);
ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(handle);
}
#include "zend.h"
-//???typedef void (*zend_objects_store_dtor_t)(zend_object *object TSRMLS_DC);
-//???typedef void (*zend_objects_free_object_storage_t)(void *object TSRMLS_DC);
-//???typedef void (*zend_objects_store_clone_t)(zend_object *object, zend_object **object_clone TSRMLS_DC);
-
-//???typedef union _zend_object_store_bucket {
-//??? zend_object *object;
-//??? int next_free;
-//??? zend_bool destructor_called;
-//??? zend_bool valid;
-//??? zend_uchar apply_count;
-//??? union _store_bucket {
-//??? struct _store_object {
-//??? zend_object *object;
-//??? zend_objects_store_dtor_t dtor;
-//??? zend_objects_free_object_storage_t free_storage;
-//??? zend_objects_store_clone_t clone;
-//??? const zend_object_handlers *handlers;
-//??? zend_uint refcount;
-//??? gc_root_buffer *buffered;
-//??? } obj;
-//??? zend_object *obj;
-//??? struct {
-//??? int next;
-//??? } free_list;
-//??? } bucket;
-//???} zend_object_store_bucket;
-
-#define FREE_BUCKET 1
-
-#define IS_VALID(o) (!(((zend_uintptr_t)(o)) & FREE_BUCKET))
-
-#define SET_INVALID(o) ((zend_object*)((((zend_uintptr_t)(o)) | FREE_BUCKET)))
-
-#define GET_BUCKET_NUMBER(o) (((zend_intptr_t)(o)) >> 1)
-
-#define SET_BUCKET_NUMBER(o, n) do { \
- (o) = (zend_object*)((((zend_uintptr_t)(n)) << 1) | FREE_BUCKET); \
+#define OBJ_BUCKET_INVALID (1<<0)
+
+#define IS_OBJ_VALID(o) (!(((zend_uintptr_t)(o)) & OBJ_BUCKET_INVALID))
+
+#define SET_OBJ_INVALID(o) ((zend_object*)((((zend_uintptr_t)(o)) | OBJ_BUCKET_INVALID)))
+
+#define GET_OBJ_BUCKET_NUMBER(o) (((zend_intptr_t)(o)) >> 1)
+
+#define SET_OBJ_BUCKET_NUMBER(o, n) do { \
+ (o) = (zend_object*)((((zend_uintptr_t)(n)) << 1) | OBJ_BUCKET_INVALID); \
} while (0)
ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects TSRMLS_DC);
-#define ZEND_OBJECTS_STORE_HANDLERS zend_object_free, zend_object_std_dtor, zend_objects_clone_obj
+#define ZEND_OBJECTS_STORE_HANDLERS 0, zend_object_std_dtor, zend_objects_destroy_object, zend_objects_clone_obj
ZEND_API zend_object *zend_object_create_proxy(zval *object, zval *member TSRMLS_DC);
/* object flags (zval.value->gc.u.flags) */
#define IS_OBJ_APPLY_COUNT 0x07
#define IS_OBJ_DESTRUCTOR_CALLED (1<<3)
+#define IS_OBJ_FREE_CALLED (1<<4)
#define Z_OBJ_APPLY_COUNT(zval) \
(Z_GC_FLAGS(zval) & IS_OBJ_APPLY_COUNT)
date_period_it_invalidate_current(iter TSRMLS_CC);
zval_ptr_dtor(&iterator->intern.data);
-
- efree(iterator);
}
/* }}} */
ce_date.create_object = date_object_new_date;
date_ce_date = zend_register_internal_class_ex(&ce_date, NULL TSRMLS_CC);
memcpy(&date_object_handlers_date, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ date_object_handlers_date.offset = XtOffsetOf(php_date_obj, std);
date_object_handlers_date.free_obj = date_object_free_storage_date;
date_object_handlers_date.clone_obj = date_object_clone_date;
date_object_handlers_date.compare_objects = date_object_compare_date;
ce_timezone.create_object = date_object_new_timezone;
date_ce_timezone = zend_register_internal_class_ex(&ce_timezone, NULL TSRMLS_CC);
memcpy(&date_object_handlers_timezone, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ date_object_handlers_timezone.offset = XtOffsetOf(php_timezone_obj, std);
date_object_handlers_timezone.free_obj = date_object_free_storage_timezone;
date_object_handlers_timezone.clone_obj = date_object_clone_timezone;
date_object_handlers_timezone.get_properties = date_object_get_properties_timezone;
ce_interval.create_object = date_object_new_interval;
date_ce_interval = zend_register_internal_class_ex(&ce_interval, NULL TSRMLS_CC);
memcpy(&date_object_handlers_interval, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ date_object_handlers_interval.offset = XtOffsetOf(php_interval_obj, std);
date_object_handlers_interval.free_obj = date_object_free_storage_interval;
date_object_handlers_interval.clone_obj = date_object_clone_interval;
date_object_handlers_interval.read_property = date_interval_read_property;
date_ce_period->iterator_funcs.funcs = &date_period_it_funcs;
zend_class_implements(date_ce_period TSRMLS_CC, 1, zend_ce_traversable);
memcpy(&date_object_handlers_period, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ date_object_handlers_period.offset = XtOffsetOf(php_period_obj, std);
date_object_handlers_period.free_obj = date_object_free_storage_period;
date_object_handlers_period.clone_obj = date_object_clone_period;
date_object_handlers_period.get_properties = date_object_get_properties_period;
}
zend_object_std_dtor(&intern->std TSRMLS_CC);
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
} /* }}} */
static void date_object_free_storage_timezone(zend_object *object TSRMLS_DC) /* {{{ */
free(intern->tzi.z.abbr);
}
zend_object_std_dtor(&intern->std TSRMLS_CC);
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
} /* }}} */
static void date_object_free_storage_interval(zend_object *object TSRMLS_DC) /* {{{ */
timelib_rel_time_dtor(intern->diff);
zend_object_std_dtor(&intern->std TSRMLS_CC);
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
} /* }}} */
static void date_object_free_storage_period(zend_object *object TSRMLS_DC) /* {{{ */
timelib_rel_time_dtor(intern->interval);
zend_object_std_dtor(&intern->std TSRMLS_CC);
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
} /* }}} */
/* Advanced Interface */
TSRMLS_FETCH();
#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO
- GC_REMOVE_FROM_BUFFER(Z_OBJ_P(zvalue));
+//??? GC_REMOVE_FROM_BUFFER(Z_OBJ_P(zvalue));
#endif
- zend_objects_store_del(Z_OBJ_P(zvalue) TSRMLS_CC);
+ OBJ_RELEASE(Z_OBJ_P(zvalue));
}
break;
case IS_RESOURCE:
intern->ptr = NULL;
zval_ptr_dtor(&intern->obj);
zend_object_std_dtor(object TSRMLS_CC);
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
}
/* }}} */
zend_std_obj_handlers = zend_get_std_object_handlers();
memcpy(&reflection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ reflection_object_handlers.offset = XtOffsetOf(reflection_object, zo);
reflection_object_handlers.free_obj = reflection_free_objects_storage;
reflection_object_handlers.clone_obj = NULL;
reflection_object_handlers.write_property = _reflection_write_property;
zend_hash_destroy(intern->debug_info);
efree(intern->debug_info);
}
-
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
}
/* }}} */
{
zend_user_it_invalidate_current(iter TSRMLS_CC);
zval_ptr_dtor(&iter->data);
-
- efree(iter);
}
/* }}} */
REGISTER_SPL_IMPLEMENTS(ArrayObject, Countable);
memcpy(&spl_handler_ArrayObject, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ spl_handler_ArrayObject.offset = XtOffsetOf(spl_array_object, std);
+
spl_handler_ArrayObject.clone_obj = spl_array_object_clone;
spl_handler_ArrayObject.read_dimension = spl_array_read_dimension;
spl_handler_ArrayObject.write_dimension = spl_array_write_dimension;
if (intern->it) {
//????zend_iterator_dtor(&intern->it->intern);
}
-
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
} /* }}} */
/* {{{ spl_ce_dir_object_new */
zval *object = &iterator->intern.data;
zval_ptr_dtor(object);
}
- efree(iterator);
/* Otherwise we were called from the owning object free storage handler as
* it sets
* iterator->intern.data to NULL.
ZVAL_UNDEF(&iterator->current);
}
}
- efree(iter);
}
/* }}} */
{
REGISTER_SPL_STD_CLASS_EX(SplFileInfo, spl_filesystem_object_new, spl_SplFileInfo_functions);
memcpy(&spl_filesystem_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- spl_filesystem_object_handlers.clone_obj = spl_filesystem_object_clone;
+ spl_filesystem_object_handlers.offset = XtOffsetOf(spl_filesystem_object, std);
+ spl_filesystem_object_handlers.clone_obj = spl_filesystem_object_clone;
spl_filesystem_object_handlers.cast_object = spl_filesystem_object_cast;
spl_filesystem_object_handlers.get_debug_info = spl_filesystem_object_get_debug_info;
spl_filesystem_object_handlers.dtor_obj = zend_objects_destroy_object;
zend_hash_destroy(intern->debug_info);
efree(intern->debug_info);
}
-
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
}
/* }}} */
zend_user_it_invalidate_current(iter TSRMLS_CC);
zval_ptr_dtor(&iterator->intern.it.data);
-
- efree(iterator);
}
/* }}} */
REGISTER_SPL_STD_CLASS_EX(SplDoublyLinkedList, spl_dllist_object_new, spl_funcs_SplDoublyLinkedList);
memcpy(&spl_handler_SplDoublyLinkedList, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ spl_handler_SplDoublyLinkedList.offset = XtOffsetOf(spl_dllist_object, std);
spl_handler_SplDoublyLinkedList.clone_obj = spl_dllist_object_clone;
spl_handler_SplDoublyLinkedList.count_elements = spl_dllist_object_count_elements;
spl_handler_SplDoublyLinkedList.get_debug_info = spl_dllist_object_get_debug_info;
zend_object_std_dtor(&intern->std TSRMLS_CC);
zval_ptr_dtor(&intern->retval);
-
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
}
/* }}} */
zend_user_it_invalidate_current(iter TSRMLS_CC);
zval_ptr_dtor(&iterator->intern.it.data);
-
- efree(iterator);
}
/* }}} */
REGISTER_SPL_STD_CLASS_EX(SplFixedArray, spl_fixedarray_new, spl_funcs_SplFixedArray);
memcpy(&spl_handler_SplFixedArray, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ spl_handler_SplFixedArray.offset = XtOffsetOf(spl_fixedarray_object, std);
spl_handler_SplFixedArray.clone_obj = spl_fixedarray_object_clone;
spl_handler_SplFixedArray.read_dimension = spl_fixedarray_object_read_dimension;
spl_handler_SplFixedArray.write_dimension = spl_fixedarray_object_write_dimension;
if (heap->count+1 > heap->max_size) {
/* we need to allocate more memory */
+ heap->elements = erealloc(heap->elements, heap->max_size * 2 * sizeof(zval));
+ memset(heap->elements + heap->max_size, 0, heap->max_size * sizeof(zval));
heap->max_size *= 2;
- heap->elements = erealloc(heap->elements, heap->max_size * sizeof(zval));
- memset(heap->elements + heap->max_size/2 * sizeof(zval), 0, heap->max_size/2 * sizeof(zval));
}
heap->ctor(elem TSRMLS_CC);
zend_hash_destroy(intern->debug_info);
efree(intern->debug_info);
}
-
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
}
/* }}} */
zend_user_it_invalidate_current(iter TSRMLS_CC);
zval_ptr_dtor(&iterator->intern.it.data);
-
- efree(iterator);
}
/* }}} */
REGISTER_SPL_STD_CLASS_EX(SplHeap, spl_heap_object_new, spl_funcs_SplHeap);
memcpy(&spl_handler_SplHeap, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ spl_handler_SplHeap.offset = XtOffsetOf(spl_heap_object, std);
spl_handler_SplHeap.clone_obj = spl_heap_object_clone;
spl_handler_SplHeap.count_elements = spl_heap_object_count_elements;
spl_handler_SplHeap.get_debug_info = spl_heap_object_get_debug_info;
REGISTER_SPL_STD_CLASS_EX(SplPriorityQueue, spl_heap_object_new, spl_funcs_SplPriorityQueue);
memcpy(&spl_handler_SplPriorityQueue, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ spl_handler_SplPriorityQueue.offset = XtOffsetOf(spl_heap_object, std);
spl_handler_SplPriorityQueue.clone_obj = spl_heap_object_clone;
spl_handler_SplPriorityQueue.count_elements = spl_heap_object_count_elements;
spl_handler_SplPriorityQueue.get_debug_info = spl_pqueue_object_get_debug_info;
object->level = 0;
zval_ptr_dtor(&iter->intern.data);
- efree(iter);
}
static int spl_recursive_it_valid_ex(spl_recursive_it_object *object, zval *zthis TSRMLS_DC)
smart_str_free(&object->prefix[5]);
smart_str_free(&object->postfix[0]);
-
- GC_REMOVE_FROM_BUFFER(_object);
- efree(object);
}
/* }}} */
}
}
- //zend_object_std_dtor(&object->std TSRMLS_CC);
-
- GC_REMOVE_FROM_BUFFER(_object);
- efree(object);
+ //???zend_object_std_dtor(&object->std TSRMLS_CC);
}
/* }}} */
REGISTER_SPL_ITERATOR(RecursiveIteratorIterator);
memcpy(&spl_handlers_rec_it_it, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ spl_handlers_rec_it_it.offset = XtOffsetOf(spl_recursive_it_object, std);
spl_handlers_rec_it_it.get_method = spl_recursive_it_get_method;
spl_handlers_rec_it_it.clone_obj = NULL;
spl_handlers_rec_it_it.dtor_obj = spl_RecursiveIteratorIterator_dtor;
spl_handlers_rec_it_it.free_obj = spl_RecursiveIteratorIterator_free_storage;
memcpy(&spl_handlers_dual_it, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ spl_handlers_dual_it.offset = XtOffsetOf(spl_dual_it_object, std);
spl_handlers_dual_it.get_method = spl_dual_it_get_method;
/*spl_handlers_dual_it.call_method = spl_dual_it_call_method;*/
spl_handlers_dual_it.clone_obj = NULL;
zend_hash_destroy(intern->debug_info);
efree(intern->debug_info);
}
-
- GC_REMOVE_FROM_BUFFER(object);
- efree(intern);
} /* }}} */
static zend_string *spl_object_storage_get_hash(spl_SplObjectStorage *intern, zval *this, zval *obj TSRMLS_DC) {
REGISTER_SPL_STD_CLASS_EX(SplObjectStorage, spl_SplObjectStorage_new, spl_funcs_SplObjectStorage);
memcpy(&spl_handler_SplObjectStorage, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+ spl_handler_SplObjectStorage.offset = XtOffsetOf(spl_SplObjectStorage, std);
spl_handler_SplObjectStorage.get_debug_info = spl_object_storage_debug_info;
spl_handler_SplObjectStorage.compare_objects = spl_object_storage_compare_objects;
spl_handler_SplObjectStorage.clone_obj = spl_object_storage_clone;