summaryrefslogtreecommitdiff
path: root/Zend/zend_list.c
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-08-28 15:41:27 +0200
committerGeorge Peter Banyard <girgias@php.net>2020-08-28 15:41:27 +0200
commitfa8d9b1183f961cb6e0f0ef5a2d1b1d3744fe35b (patch)
treea00044117c3f56969a7b77b466bbdbdd45d66db7 /Zend/zend_list.c
parent7690439edd93bf9dc868cbc34a12fbad6b26e777 (diff)
downloadphp-git-fa8d9b1183f961cb6e0f0ef5a2d1b1d3744fe35b.tar.gz
Improve type declarations for Zend APIs
Voidification of Zend API which always succeeded Use bool argument types instead of int for boolean arguments Use bool return type for functions which return true/false (1/0) Use zend_result return type for functions which return SUCCESS/FAILURE as they don't follow normal boolean semantics Closes GH-6002
Diffstat (limited to 'Zend/zend_list.c')
-rw-r--r--Zend/zend_list.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/Zend/zend_list.c b/Zend/zend_list.c
index fd3db65395..45ff950b6b 100644
--- a/Zend/zend_list.c
+++ b/Zend/zend_list.c
@@ -42,7 +42,7 @@ ZEND_API zval* ZEND_FASTCALL zend_list_insert(void *ptr, int type)
return zend_hash_index_add_new(&EG(regular_list), index, &zv);
}
-ZEND_API int ZEND_FASTCALL zend_list_delete(zend_resource *res)
+ZEND_API zend_result ZEND_FASTCALL zend_list_delete(zend_resource *res)
{
if (GC_DELREF(res) <= 0) {
return zend_hash_index_del(&EG(regular_list), res->handle);
@@ -76,14 +76,13 @@ static void zend_resource_dtor(zend_resource *res)
}
-ZEND_API int ZEND_FASTCALL zend_list_close(zend_resource *res)
+ZEND_API void ZEND_FASTCALL zend_list_close(zend_resource *res)
{
if (GC_REFCOUNT(res) <= 0) {
zend_list_free(res);
} else if (res->type >= 0) {
zend_resource_dtor(res);
}
- return SUCCESS;
}
ZEND_API zend_resource* zend_register_resource(void *rsrc_pointer, int rsrc_type)
@@ -203,18 +202,16 @@ void plist_entry_destructor(zval *zv)
free(res);
}
-ZEND_API int zend_init_rsrc_list(void)
+ZEND_API void zend_init_rsrc_list(void)
{
zend_hash_init(&EG(regular_list), 8, NULL, list_entry_destructor, 0);
EG(regular_list).nNextFreeElement = 0;
- return SUCCESS;
}
-int zend_init_rsrc_plist(void)
+void zend_init_rsrc_plist(void)
{
zend_hash_init(&EG(persistent_list), 8, NULL, plist_entry_destructor, 1);
- return SUCCESS;
}
@@ -235,6 +232,7 @@ void zend_destroy_rsrc_list(HashTable *ht)
zend_hash_graceful_reverse_destroy(ht);
}
+/* int return due to HashTable API */
static int clean_module_resource(zval *zv, void *arg)
{
int resource_id = *(int *)arg;
@@ -242,7 +240,7 @@ static int clean_module_resource(zval *zv, void *arg)
return Z_RES_TYPE_P(zv) == resource_id;
}
-
+/* int return due to HashTable API */
static int zend_clean_module_rsrc_dtors_cb(zval *zv, void *arg)
{
zend_rsrc_list_dtors_entry *ld = (zend_rsrc_list_dtors_entry *)Z_PTR_P(zv);
@@ -299,11 +297,10 @@ static void list_destructors_dtor(zval *zv)
free(Z_PTR_P(zv));
}
-int zend_init_rsrc_list_dtors(void)
+void zend_init_rsrc_list_dtors(void)
{
zend_hash_init(&list_destructors, 64, NULL, list_destructors_dtor, 1);
list_destructors.nNextFreeElement=1; /* we don't want resource type 0 */
- return SUCCESS;
}