]> granicus.if.org Git - php/commitdiff
Cleanup. Removed unused functions and unimplemented prototype. Avoid useless "dtor_ob...
authorDmitry Stogov <dmitry@zend.com>
Tue, 27 Jun 2017 09:03:06 +0000 (12:03 +0300)
committerDmitry Stogov <dmitry@zend.com>
Tue, 27 Jun 2017 09:03:06 +0000 (12:03 +0300)
Zend/zend_objects.c
Zend/zend_objects_API.c
Zend/zend_objects_API.h

index 8f090d2097b13d200204d5ed844b6b690910c7ed..2c038042fc31201e08dffc166b8ddb99d37a2fc9 100644 (file)
@@ -76,7 +76,7 @@ ZEND_API void zend_object_std_dtor(zend_object *object)
 
 ZEND_API void zend_objects_destroy_object(zend_object *object)
 {
-       zend_function *destructor = object ? object->ce->destructor : NULL;
+       zend_function *destructor = object->ce->destructor;
 
        if (destructor) {
                zend_object *old_exception;
index f838eddc9755e707cf333c9fd7bf3454ab674e9c..6c622c6702ad15c83d7c89d82ee85617fb22ad60 100644 (file)
@@ -50,9 +50,14 @@ ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects)
                        if (IS_OBJ_VALID(obj)) {
                                if (!(GC_FLAGS(obj) & IS_OBJ_DESTRUCTOR_CALLED)) {
                                        GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
-                                       GC_REFCOUNT(obj)++;
-                                       obj->handlers->dtor_obj(obj);
-                                       GC_REFCOUNT(obj)--;
+
+                                       if (obj->handlers->dtor_obj
+                                        && (obj->handlers->dtor_obj != zend_objects_destroy_object
+                                         || obj->ce->destructor)) {
+                                               GC_REFCOUNT(obj)++;
+                                               obj->handlers->dtor_obj(obj);
+                                               GC_REFCOUNT(obj)--;
+                                       }
                                }
                        }
                }
@@ -149,17 +154,6 @@ ZEND_API void zend_objects_store_put(zend_object *object)
             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) /* {{{ */
-{
-       uint32_t handle = object->handle;
-       void *ptr = ((char*)object) - object->handlers->offset;
-
-       GC_REMOVE_FROM_BUFFER(object);
-       efree(ptr);
-       ZEND_OBJECTS_STORE_ADD_TO_FREE_LIST(handle);
-}
-/* }}} */
-
 ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */
 {
        /*      Make sure we hold a reference count during the destructor call
@@ -172,7 +166,9 @@ ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */
                        if (!(GC_FLAGS(object) & IS_OBJ_DESTRUCTOR_CALLED)) {
                                GC_FLAGS(object) |= IS_OBJ_DESTRUCTOR_CALLED;
 
-                               if (object->handlers->dtor_obj) {
+                               if (object->handlers->dtor_obj
+                                && (object->handlers->dtor_obj != zend_objects_destroy_object
+                                 || object->ce->destructor)) {
                                        GC_REFCOUNT(object)++;
                                        object->handlers->dtor_obj(object);
                                        GC_REFCOUNT(object)--;
@@ -204,18 +200,6 @@ ZEND_API void zend_objects_store_del(zend_object *object) /* {{{ */
 }
 /* }}} */
 
-/* zend_object_store_set_object:
- * It is ONLY valid to call this function from within the constructor of an
- * overloaded object.  Its purpose is to set the object pointer for the object
- * when you can't possibly know its value until you have parsed the arguments
- * from the constructor function.  You MUST NOT use this function for any other
- * weird games, or call it at any other time after the object is constructed.
- * */
-ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object)
-{
-       EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(zobject)] = object;
-}
-
 ZEND_API zend_object_handlers *zend_get_std_object_handlers(void)
 {
        return &std_object_handlers;
index b105def1766df80b0c0131b4779847c1a3e15750..a1bc6e681066bfcaaafe40afa95c43644f287182 100644 (file)
@@ -52,15 +52,12 @@ BEGIN_EXTERN_C()
 ZEND_API void zend_objects_store_init(zend_objects_store *objects, uint32_t init_size);
 ZEND_API void zend_objects_store_call_destructors(zend_objects_store *objects);
 ZEND_API void zend_objects_store_mark_destructed(zend_objects_store *objects);
+ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects, zend_bool fast_shutdown);
 ZEND_API void zend_objects_store_destroy(zend_objects_store *objects);
 
 /* Store API functions */
 ZEND_API void zend_objects_store_put(zend_object *object);
 ZEND_API void zend_objects_store_del(zend_object *object);
-ZEND_API void zend_objects_store_free(zend_object *object);
-
-/* See comment in zend_objects_API.c before you use this */
-ZEND_API void zend_object_store_set_object(zval *zobject, zend_object *object);
 
 /* Called when the ctor was terminated by an exception */
 static zend_always_inline void zend_object_store_ctor_failed(zend_object *obj)
@@ -68,12 +65,8 @@ static zend_always_inline void zend_object_store_ctor_failed(zend_object *obj)
        GC_FLAGS(obj) |= IS_OBJ_DESTRUCTOR_CALLED;
 }
 
-ZEND_API void zend_objects_store_free_object_storage(zend_objects_store *objects, zend_bool fast_shutdown);
-
 #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);
-
 ZEND_API zend_object_handlers *zend_get_std_object_handlers(void);
 END_EXTERN_C()