diff options
author | George Peter Banyard <girgias@php.net> | 2020-08-28 15:41:27 +0200 |
---|---|---|
committer | George Peter Banyard <girgias@php.net> | 2020-08-28 15:41:27 +0200 |
commit | fa8d9b1183f961cb6e0f0ef5a2d1b1d3744fe35b (patch) | |
tree | a00044117c3f56969a7b77b466bbdbdd45d66db7 /Zend/zend_alloc.c | |
parent | 7690439edd93bf9dc868cbc34a12fbad6b26e777 (diff) | |
download | php-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_alloc.c')
-rw-r--r-- | Zend/zend_alloc.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index 69b7baca40..098dda104a 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -2203,7 +2203,7 @@ static void *tracked_malloc(size_t size); static void tracked_free_all(); #endif -void zend_mm_shutdown(zend_mm_heap *heap, int full, int silent) +void zend_mm_shutdown(zend_mm_heap *heap, bool full, bool silent) { zend_mm_chunk *p; zend_mm_huge_list *list; @@ -2365,7 +2365,7 @@ static size_t alloc_globals_offset; static zend_alloc_globals alloc_globals; #endif -ZEND_API int is_zend_mm(void) +ZEND_API bool is_zend_mm(void) { #if ZEND_MM_CUSTOM return !AG(mm_heap)->use_custom_heap; @@ -2374,7 +2374,7 @@ ZEND_API int is_zend_mm(void) #endif } -ZEND_API int is_zend_ptr(const void *ptr) +ZEND_API bool is_zend_ptr(const void *ptr) { #if ZEND_MM_CUSTOM if (AG(mm_heap)->use_custom_heap) { @@ -2658,15 +2658,14 @@ ZEND_API char* ZEND_FASTCALL zend_strndup(const char *s, size_t length) } -ZEND_API int zend_set_memory_limit(size_t memory_limit) +ZEND_API void zend_set_memory_limit(size_t memory_limit) { #if ZEND_MM_LIMIT AG(mm_heap)->limit = (memory_limit >= ZEND_MM_CHUNK_SIZE) ? memory_limit : ZEND_MM_CHUNK_SIZE; #endif - return SUCCESS; } -ZEND_API size_t zend_memory_usage(int real_usage) +ZEND_API size_t zend_memory_usage(bool real_usage) { #if ZEND_MM_STAT if (real_usage) { @@ -2679,7 +2678,7 @@ ZEND_API size_t zend_memory_usage(int real_usage) return 0; } -ZEND_API size_t zend_memory_peak_usage(int real_usage) +ZEND_API size_t zend_memory_peak_usage(bool real_usage) { #if ZEND_MM_STAT if (real_usage) { @@ -2691,7 +2690,7 @@ ZEND_API size_t zend_memory_peak_usage(int real_usage) return 0; } -ZEND_API void shutdown_memory_manager(int silent, int full_shutdown) +ZEND_API void shutdown_memory_manager(bool silent, bool full_shutdown) { zend_mm_shutdown(AG(mm_heap), full_shutdown, silent); } @@ -2858,7 +2857,7 @@ ZEND_API zend_mm_heap *zend_mm_get_heap(void) return AG(mm_heap); } -ZEND_API int zend_mm_is_custom_heap(zend_mm_heap *new_heap) +ZEND_API bool zend_mm_is_custom_heap(zend_mm_heap *new_heap) { #if ZEND_MM_CUSTOM return AG(mm_heap)->use_custom_heap; |