if (gc_flags & GC_HAS_DESTRUCTORS) {
GC_TRACE("Calling destructors");
- if (EG(objects_store).object_buckets) {
- /* Remember reference counters before calling destructors */
- current = to_free.next;
- while (current != &to_free) {
- current->refcount = GC_REFCOUNT(current->ref);
- current = current->next;
- }
- /* Call destructors */
- current = to_free.next;
- while (current != &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 (IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
- !(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
- GC_TRACE_REF(obj, "calling destructor");
- GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
- if (obj->handlers->dtor_obj) {
- GC_REFCOUNT(obj)++;
- obj->handlers->dtor_obj(obj);
- GC_REFCOUNT(obj)--;
- }
+ /* Remember reference counters before calling destructors */
+ current = to_free.next;
+ while (current != &to_free) {
+ current->refcount = GC_REFCOUNT(current->ref);
+ current = current->next;
+ }
+
+ /* Call destructors */
+ current = to_free.next;
+ while (current != &to_free) {
+ p = current->ref;
+ GC_G(next_to_free) = current->next;
- if ((GC_TYPE(p) & GC_TYPE_MASK) == IS_OBJECT) {
++ if (GC_TYPE(p) == IS_OBJECT) {
+ zend_object *obj = (zend_object*)p;
+
+ if (IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
+ !(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
+ GC_TRACE_REF(obj, "calling destructor");
+ GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
+ if (obj->handlers->dtor_obj) {
+ GC_REFCOUNT(obj)++;
+ obj->handlers->dtor_obj(obj);
+ GC_REFCOUNT(obj)--;
}
}
- current = GC_G(next_to_free);
}
+ current = GC_G(next_to_free);
+ }
- /* Remove values captured in destructors */
- current = to_free.next;
- while (current != &to_free) {
- GC_G(next_to_free) = current->next;
- if (GC_REFCOUNT(current->ref) > current->refcount) {
- gc_remove_nested_data_from_buffer(current->ref, current);
- }
- current = GC_G(next_to_free);
+ /* Remove values captured in destructors */
+ current = to_free.next;
+ while (current != &to_free) {
+ GC_G(next_to_free) = current->next;
+ if (GC_REFCOUNT(current->ref) > current->refcount) {
+ gc_remove_nested_data_from_buffer(current->ref, current);
}
+ current = GC_G(next_to_free);
}
}
p = current->ref;
GC_G(next_to_free) = current->next;
GC_TRACE_REF(p, "destroying");
- if ((GC_TYPE(p) & GC_TYPE_MASK) == IS_OBJECT) {
+ 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])) {
+ if (IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle])) {
EG(objects_store).object_buckets[obj->handle] = SET_OBJ_INVALID(obj);
GC_TYPE(obj) = IS_NULL;
if (!(GC_FLAGS(obj) & IS_OBJ_FREE_CALLED)) {