]> granicus.if.org Git - php/commitdiff
Make zend_list_free return void
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 15 Apr 2020 08:49:44 +0000 (10:49 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Wed, 15 Apr 2020 09:01:12 +0000 (11:01 +0200)
And assert that the refcount is zero. This function should only
be used internally as the resource destructor.

Zend/zend_list.c
Zend/zend_list.h

index 2288cf6913c7f74c94d04c838b7a7fb195da708d..3464ca27d524df5b0afeb19e48610e9708a388b8 100644 (file)
@@ -51,13 +51,10 @@ ZEND_API int ZEND_FASTCALL zend_list_delete(zend_resource *res)
        }
 }
 
-ZEND_API int ZEND_FASTCALL zend_list_free(zend_resource *res)
+ZEND_API void ZEND_FASTCALL zend_list_free(zend_resource *res)
 {
-       if (GC_REFCOUNT(res) <= 0) {
-               return zend_hash_index_del(&EG(regular_list), res->handle);
-       } else {
-               return SUCCESS;
-       }
+       ZEND_ASSERT(GC_REFCOUNT(res) == 0);
+       zend_hash_index_del(&EG(regular_list), res->handle);
 }
 
 static void zend_resource_dtor(zend_resource *res)
@@ -82,7 +79,7 @@ static void zend_resource_dtor(zend_resource *res)
 ZEND_API int ZEND_FASTCALL zend_list_close(zend_resource *res)
 {
        if (GC_REFCOUNT(res) <= 0) {
-               return zend_list_free(res);
+               zend_list_free(res);
        } else if (res->type >= 0) {
                zend_resource_dtor(res);
        }
index b9a1d5e159a2725e05fd943fb1167f44ce1fe294..92fdd3d4178f3bda632fb350ad534e8ca0f2e66f 100644 (file)
@@ -53,7 +53,7 @@ int zend_init_rsrc_list_dtors(void);
 void zend_destroy_rsrc_list_dtors(void);
 
 ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type);
-ZEND_API int ZEND_FASTCALL zend_list_free(zend_resource *res);
+ZEND_API void ZEND_FASTCALL zend_list_free(zend_resource *res);
 ZEND_API int ZEND_FASTCALL zend_list_delete(zend_resource *res);
 ZEND_API int ZEND_FASTCALL zend_list_close(zend_resource *res);