diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c index 66cfb250d1fec..7eeaa31be765e 100644 --- a/Zend/zend_hash.c +++ b/Zend/zend_hash.c @@ -51,7 +51,7 @@ #define HT_DESTROYED 0x02 #define HT_CLEANING 0x03 -static void _zend_is_inconsistent(const HashTable *ht, const char *file, int line) +ZEND_ATTRIBUTE_NONNULL static void _zend_is_inconsistent(const HashTable *ht, const char *file, int line) { if ((HT_FLAGS(ht) & HASH_FLAG_CONSISTENCY) == HT_OK) { return; @@ -86,7 +86,7 @@ static void _zend_is_inconsistent(const HashTable *ht, const char *file, int lin zend_hash_do_resize(ht); \ } -ZEND_API void *zend_hash_str_find_ptr_lc(const HashTable *ht, const char *str, size_t len) { +ZEND_ATTRIBUTE_NONNULL ZEND_API void *zend_hash_str_find_ptr_lc(const HashTable *ht, const char *str, size_t len) { void *result; char *lc_str; @@ -100,7 +100,7 @@ ZEND_API void *zend_hash_str_find_ptr_lc(const HashTable *ht, const char *str, s return result; } -ZEND_API void *zend_hash_find_ptr_lc(const HashTable *ht, zend_string *key) { +ZEND_ATTRIBUTE_NONNULL ZEND_API void *zend_hash_find_ptr_lc(const HashTable *ht, zend_string *key) { void *result; zend_string *lc_key = zend_string_tolower(key); result = zend_hash_find_ptr(ht, lc_key); @@ -145,7 +145,7 @@ static zend_always_inline uint32_t zend_hash_check_size(uint32_t nSize) #endif } -static zend_always_inline void zend_hash_real_init_packed_ex(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_hash_real_init_packed_ex(HashTable *ht) { void *data; @@ -163,7 +163,7 @@ static zend_always_inline void zend_hash_real_init_packed_ex(HashTable *ht) HT_HASH_RESET_PACKED(ht); } -static zend_always_inline void zend_hash_real_init_mixed_ex(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_hash_real_init_mixed_ex(HashTable *ht) { void *data; uint32_t nSize = ht->nTableSize; @@ -230,7 +230,7 @@ static zend_always_inline void zend_hash_real_init_mixed_ex(HashTable *ht) HT_HASH_RESET(ht); } -static zend_always_inline void zend_hash_real_init_ex(HashTable *ht, bool packed) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_hash_real_init_ex(HashTable *ht, bool packed) { HT_ASSERT_RC1(ht); ZEND_ASSERT(HT_FLAGS(ht) & HASH_FLAG_UNINITIALIZED); @@ -292,7 +292,7 @@ ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t nSize) return ht; } -ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(const zval *val1, const zval *val2) +ZEND_ATTRIBUTE_NONNULL ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(const zval *val1, const zval *val2) { zval *zv; HashTable *ht = emalloc(sizeof(HashTable)); @@ -307,7 +307,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(const zval *val1, const zval *va return ht; } -ZEND_API void ZEND_FASTCALL zend_hash_packed_grow(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_packed_grow(HashTable *ht) { HT_ASSERT_RC1(ht); if (ht->nTableSize >= HT_MAX_SIZE) { @@ -318,7 +318,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_packed_grow(HashTable *ht) ht->nTableSize = newTableSize; } -ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, bool packed) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, bool packed) { IS_CONSISTENT(ht); @@ -326,7 +326,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, bool packed) zend_hash_real_init_ex(ht, packed); } -ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht) { IS_CONSISTENT(ht); @@ -334,7 +334,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht) zend_hash_real_init_packed_ex(ht); } -ZEND_API void ZEND_FASTCALL zend_hash_real_init_mixed(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_real_init_mixed(HashTable *ht) { IS_CONSISTENT(ht); @@ -342,7 +342,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_real_init_mixed(HashTable *ht) zend_hash_real_init_mixed_ex(ht); } -ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht) { void *new_data, *old_data = HT_GET_DATA_ADDR(ht); zval *src = ht->arPacked; @@ -370,7 +370,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht) zend_hash_rehash(ht); } -ZEND_API void ZEND_FASTCALL zend_hash_to_packed(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_to_packed(HashTable *ht) { void *new_data, *old_data = HT_GET_DATA_ADDR(ht); Bucket *src = ht->arData; @@ -392,7 +392,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_to_packed(HashTable *ht) pefree(old_data, GC_FLAGS(ht) & IS_ARRAY_PERSISTENT); } -ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool packed) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool packed) { HT_ASSERT_RC1(ht); @@ -431,7 +431,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool } } -ZEND_API void ZEND_FASTCALL zend_hash_discard(HashTable *ht, uint32_t nNumUsed) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_discard(HashTable *ht, uint32_t nNumUsed) { Bucket *p, *end, *arData; uint32_t nIndex; @@ -456,7 +456,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_discard(HashTable *ht, uint32_t nNumUsed) } } -static uint32_t zend_array_recalc_elements(const HashTable *ht) +ZEND_ATTRIBUTE_NONNULL static uint32_t zend_array_recalc_elements(const HashTable *ht) { zval *val; uint32_t num = ht->nNumOfElements; @@ -472,7 +472,7 @@ static uint32_t zend_array_recalc_elements(const HashTable *ht) } /* }}} */ -ZEND_API uint32_t zend_array_count(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API uint32_t zend_array_count(HashTable *ht) { uint32_t num; if (UNEXPECTED(HT_FLAGS(ht) & HASH_FLAG_HAS_EMPTY_IND)) { @@ -489,7 +489,7 @@ ZEND_API uint32_t zend_array_count(HashTable *ht) } /* }}} */ -static zend_always_inline HashPosition _zend_hash_get_valid_pos(const HashTable *ht, HashPosition pos) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline HashPosition _zend_hash_get_valid_pos(const HashTable *ht, HashPosition pos) { if (HT_IS_PACKED(ht)) { while (pos < ht->nNumUsed && Z_ISUNDEF(ht->arPacked[pos])) { @@ -503,17 +503,17 @@ static zend_always_inline HashPosition _zend_hash_get_valid_pos(const HashTable return pos; } -static zend_always_inline HashPosition _zend_hash_get_current_pos(const HashTable *ht) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline HashPosition _zend_hash_get_current_pos(const HashTable *ht) { return _zend_hash_get_valid_pos(ht, ht->nInternalPointer); } -ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos(const HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos(const HashTable *ht) { return _zend_hash_get_current_pos(ht); } -ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos_ex(const HashTable *ht, HashPosition pos) +ZEND_ATTRIBUTE_NONNULL ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos_ex(const HashTable *ht, HashPosition pos) { return _zend_hash_get_valid_pos(ht, pos); } @@ -533,7 +533,7 @@ static void zend_hash_remove_iterator_copies(uint32_t idx) { iter->next_copy = idx; } -ZEND_API uint32_t ZEND_FASTCALL zend_hash_iterator_add(HashTable *ht, HashPosition pos) +ZEND_ATTRIBUTE_NONNULL ZEND_API uint32_t ZEND_FASTCALL zend_hash_iterator_add(HashTable *ht, HashPosition pos) { HashTableIterator *iter = EG(ht_iterators); HashTableIterator *end = iter + EG(ht_iterators_count); @@ -623,7 +623,7 @@ ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos(uint32_t idx, HashTab return iter->pos; } -ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos_ex(uint32_t idx, zval *array) +ZEND_ATTRIBUTE_NONNULL ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos_ex(uint32_t idx, zval *array) { HashTable *ht = Z_ARRVAL_P(array); HashTableIterator *iter = EG(ht_iterators) + idx; @@ -683,7 +683,7 @@ static zend_never_inline void ZEND_FASTCALL _zend_hash_iterators_remove(const Ha } } -static zend_always_inline void zend_hash_iterators_remove(const HashTable *ht) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_hash_iterators_remove(const HashTable *ht) { if (UNEXPECTED(HT_HAS_ITERATORS(ht))) { _zend_hash_iterators_remove(ht); @@ -734,7 +734,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_iterators_advance(const HashTable *ht, Has } /* Hash must be known and precomputed before */ -static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, const zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, const zend_string *key) { uint32_t nIndex; uint32_t idx; @@ -771,7 +771,7 @@ static zend_always_inline Bucket *zend_hash_find_bucket(const HashTable *ht, con } } -static zend_always_inline Bucket *zend_hash_str_find_bucket(const HashTable *ht, const char *str, size_t len, zend_ulong h) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline Bucket *zend_hash_str_find_bucket(const HashTable *ht, const char *str, size_t len, zend_ulong h) { uint32_t nIndex; uint32_t idx; @@ -793,7 +793,7 @@ static zend_always_inline Bucket *zend_hash_str_find_bucket(const HashTable *ht, return NULL; } -static zend_always_inline Bucket *zend_hash_index_find_bucket(const HashTable *ht, zend_ulong h) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline Bucket *zend_hash_index_find_bucket(const HashTable *ht, zend_ulong h) { uint32_t nIndex; uint32_t idx; @@ -813,7 +813,7 @@ static zend_always_inline Bucket *zend_hash_index_find_bucket(const HashTable *h return NULL; } -static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_string *key, zval *pData, uint32_t flag) +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) static zend_always_inline zval *_zend_hash_add_or_update_i(HashTable *ht, zend_string *key, zval *pData, uint32_t flag) { zend_ulong h; uint32_t nIndex; @@ -974,7 +974,7 @@ static zend_always_inline zval *_zend_hash_str_add_or_update_i(HashTable *ht, co return &p->val; } -ZEND_API zval* ZEND_FASTCALL zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag) { if (flag == HASH_ADD) { return zend_hash_add(ht, key, pData); @@ -988,32 +988,32 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_add_or_update(HashTable *ht, zend_string } } -ZEND_API zval* ZEND_FASTCALL zend_hash_add(HashTable *ht, zend_string *key, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_add(HashTable *ht, zend_string *key, zval *pData) { return _zend_hash_add_or_update_i(ht, key, pData, HASH_ADD); } -ZEND_API zval* ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key, zval *pData) { return _zend_hash_add_or_update_i(ht, key, pData, HASH_UPDATE); } -ZEND_API zval* ZEND_FASTCALL zend_hash_update_ind(HashTable *ht, zend_string *key, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_update_ind(HashTable *ht, zend_string *key, zval *pData) { return _zend_hash_add_or_update_i(ht, key, pData, HASH_UPDATE | HASH_UPDATE_INDIRECT); } -ZEND_API zval* ZEND_FASTCALL zend_hash_add_new(HashTable *ht, zend_string *key, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_add_new(HashTable *ht, zend_string *key, zval *pData) { return _zend_hash_add_or_update_i(ht, key, pData, HASH_ADD_NEW); } -ZEND_API zval* ZEND_FASTCALL zend_hash_lookup(HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_lookup(HashTable *ht, zend_string *key) { return _zend_hash_add_or_update_i(ht, key, NULL, HASH_LOOKUP); } -ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_or_update(HashTable *ht, const char *str, size_t len, zval *pData, uint32_t flag) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_or_update(HashTable *ht, const char *str, size_t len, zval *pData, uint32_t flag) { if (flag == HASH_ADD) { return zend_hash_str_add(ht, str, len, pData); @@ -1027,35 +1027,35 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_or_update(HashTable *ht, const ch } } -ZEND_API zval* ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *str, size_t len, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *str, size_t len, zval *pData) { zend_ulong h = zend_hash_func(str, len); return _zend_hash_str_add_or_update_i(ht, str, len, h, pData, HASH_UPDATE); } -ZEND_API zval* ZEND_FASTCALL zend_hash_str_update_ind(HashTable *ht, const char *str, size_t len, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_update_ind(HashTable *ht, const char *str, size_t len, zval *pData) { zend_ulong h = zend_hash_func(str, len); return _zend_hash_str_add_or_update_i(ht, str, len, h, pData, HASH_UPDATE | HASH_UPDATE_INDIRECT); } -ZEND_API zval* ZEND_FASTCALL zend_hash_str_add(HashTable *ht, const char *str, size_t len, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_add(HashTable *ht, const char *str, size_t len, zval *pData) { zend_ulong h = zend_hash_func(str, len); return _zend_hash_str_add_or_update_i(ht, str, len, h, pData, HASH_ADD); } -ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_new(HashTable *ht, const char *str, size_t len, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_new(HashTable *ht, const char *str, size_t len, zval *pData) { zend_ulong h = zend_hash_func(str, len); return _zend_hash_str_add_or_update_i(ht, str, len, h, pData, HASH_ADD_NEW); } -ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h) { zval dummy; @@ -1063,7 +1063,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_empty_element(HashTable *ht, ze return zend_hash_index_add(ht, h, &dummy); } -ZEND_API zval* ZEND_FASTCALL zend_hash_add_empty_element(HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_add_empty_element(HashTable *ht, zend_string *key) { zval dummy; @@ -1071,7 +1071,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_add_empty_element(HashTable *ht, zend_str return zend_hash_add(ht, key, &dummy); } -ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_empty_element(HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_empty_element(HashTable *ht, const char *str, size_t len) { zval dummy; @@ -1079,7 +1079,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_empty_element(HashTable *ht, cons return zend_hash_str_add(ht, str, len, &dummy); } -static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag) +ZEND_ATTRIBUTE_NONNULL_ARGS(1) static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag) { uint32_t nIndex; uint32_t idx; @@ -1187,7 +1187,7 @@ static zend_always_inline zval *_zend_hash_index_add_or_update_i(HashTable *ht, return &p->val; } -ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_or_update(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_or_update(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag) { if (flag == HASH_ADD) { return zend_hash_index_add(ht, h, pData); @@ -1205,37 +1205,37 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_or_update(HashTable *ht, zend_u } } -ZEND_API zval* ZEND_FASTCALL zend_hash_index_add(HashTable *ht, zend_ulong h, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_add(HashTable *ht, zend_ulong h, zval *pData) { return _zend_hash_index_add_or_update_i(ht, h, pData, HASH_ADD); } -ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData) { return _zend_hash_index_add_or_update_i(ht, h, pData, HASH_ADD | HASH_ADD_NEW); } -ZEND_API zval* ZEND_FASTCALL zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData) { return _zend_hash_index_add_or_update_i(ht, h, pData, HASH_UPDATE); } -ZEND_API zval* ZEND_FASTCALL zend_hash_next_index_insert(HashTable *ht, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_next_index_insert(HashTable *ht, zval *pData) { return _zend_hash_index_add_or_update_i(ht, ht->nNextFreeElement, pData, HASH_ADD | HASH_ADD_NEXT); } -ZEND_API zval* ZEND_FASTCALL zend_hash_next_index_insert_new(HashTable *ht, zval *pData) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_next_index_insert_new(HashTable *ht, zval *pData) { return _zend_hash_index_add_or_update_i(ht, ht->nNextFreeElement, pData, HASH_ADD | HASH_ADD_NEW | HASH_ADD_NEXT); } -ZEND_API zval* ZEND_FASTCALL zend_hash_index_lookup(HashTable *ht, zend_ulong h) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_lookup(HashTable *ht, zend_ulong h) { return _zend_hash_index_add_or_update_i(ht, h, NULL, HASH_LOOKUP); } -ZEND_API zval* ZEND_FASTCALL zend_hash_set_bucket_key(HashTable *ht, Bucket *b, zend_string *key) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_set_bucket_key(HashTable *ht, Bucket *b, zend_string *key) { uint32_t nIndex; uint32_t idx, i; @@ -1296,7 +1296,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_set_bucket_key(HashTable *ht, Bucket *b, return &b->val; } -static void ZEND_FASTCALL zend_hash_do_resize(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL static void ZEND_FASTCALL zend_hash_do_resize(HashTable *ht) { IS_CONSISTENT(ht); @@ -1324,7 +1324,7 @@ static void ZEND_FASTCALL zend_hash_do_resize(HashTable *ht) } } -ZEND_API void ZEND_FASTCALL zend_hash_rehash(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_rehash(HashTable *ht) { Bucket *p; uint32_t nIndex, i; @@ -1428,7 +1428,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_rehash(HashTable *ht) } } -static zend_always_inline void zend_hash_iterators_clamp_max(const HashTable *ht, uint32_t max) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_hash_iterators_clamp_max(const HashTable *ht, uint32_t max) { if (UNEXPECTED(HT_HAS_ITERATORS(ht))) { HashTableIterator *iter = EG(ht_iterators); @@ -1442,7 +1442,7 @@ static zend_always_inline void zend_hash_iterators_clamp_max(const HashTable *ht } } -static zend_always_inline void _zend_hash_packed_del_val(HashTable *ht, uint32_t idx, zval *zv) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void _zend_hash_packed_del_val(HashTable *ht, uint32_t idx, zval *zv) { idx = HT_HASH_TO_IDX(idx); ht->nNumOfElements--; @@ -1463,7 +1463,7 @@ static zend_always_inline void _zend_hash_packed_del_val(HashTable *ht, uint32_t } } -static zend_always_inline void _zend_hash_del_el_ex(HashTable *ht, uint32_t idx, Bucket *p, Bucket *prev) +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 3) static zend_always_inline void _zend_hash_del_el_ex(HashTable *ht, uint32_t idx, Bucket *p, Bucket *prev) { if (prev) { Z_NEXT(prev->val) = Z_NEXT(p->val); @@ -1489,7 +1489,7 @@ static zend_always_inline void _zend_hash_del_el_ex(HashTable *ht, uint32_t idx, } } -static zend_always_inline void _zend_hash_del_el(HashTable *ht, uint32_t idx, Bucket *p) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void _zend_hash_del_el(HashTable *ht, uint32_t idx, Bucket *p) { Bucket *prev = NULL; uint32_t nIndex; @@ -1513,7 +1513,7 @@ static zend_always_inline void _zend_hash_del_el(HashTable *ht, uint32_t idx, Bu _zend_hash_del_el_ex(ht, idx, p, prev); } -ZEND_API void ZEND_FASTCALL zend_hash_packed_del_val(HashTable *ht, zval *zv) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_packed_del_val(HashTable *ht, zval *zv) { IS_CONSISTENT(ht); HT_ASSERT_RC1(ht); @@ -1522,7 +1522,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_packed_del_val(HashTable *ht, zval *zv) } -ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p) { IS_CONSISTENT(ht); HT_ASSERT_RC1(ht); @@ -1530,7 +1530,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p) _zend_hash_del_el(ht, HT_IDX_TO_HASH(p - ht->arData), p); } -ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key) { zend_ulong h; uint32_t nIndex; @@ -1562,7 +1562,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key return FAILURE; } -ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key) { zend_ulong h; uint32_t nIndex; @@ -1612,7 +1612,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string return FAILURE; } -ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *str, size_t len) { zend_ulong h; uint32_t nIndex; @@ -1657,7 +1657,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const ch return FAILURE; } -ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *str, size_t len) { zend_ulong h; uint32_t nIndex; @@ -1688,7 +1688,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char * return FAILURE; } -ZEND_API zend_result ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h) +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h) { uint32_t nIndex; uint32_t idx; @@ -1723,7 +1723,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong return FAILURE; } -ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht) { IS_CONSISTENT(ht); HT_ASSERT(ht, GC_REFCOUNT(ht) <= 1); @@ -1804,7 +1804,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht) pefree(HT_GET_DATA_ADDR(ht), GC_FLAGS(ht) & IS_ARRAY_PERSISTENT); } -ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht) { IS_CONSISTENT(ht); HT_ASSERT(ht, GC_REFCOUNT(ht) <= 1); @@ -1865,7 +1865,7 @@ ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht) FREE_HASHTABLE(ht); } -ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht) { IS_CONSISTENT(ht); HT_ASSERT_RC1(ht); @@ -1942,7 +1942,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht) ht->nInternalPointer = 0; } -ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht) { Bucket *p, *end; @@ -1982,7 +1982,7 @@ ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht) ht->nInternalPointer = 0; } -ZEND_API void ZEND_FASTCALL zend_hash_graceful_destroy(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_graceful_destroy(HashTable *ht) { uint32_t idx; @@ -2011,7 +2011,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_graceful_destroy(HashTable *ht) SET_INCONSISTENT(HT_DESTROYED); } -ZEND_API void ZEND_FASTCALL zend_hash_graceful_reverse_destroy(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_graceful_reverse_destroy(HashTable *ht) { uint32_t idx; @@ -2055,7 +2055,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_graceful_reverse_destroy(HashTable *ht) * ZEND_HASH_APPLY_REMOVE - delete the element, combinable with the former */ -ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_func) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_func) { uint32_t idx; int result; @@ -2094,8 +2094,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_fu } } - -ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *argument) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *argument) { uint32_t idx; int result; @@ -2132,8 +2131,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_f } } - -ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int num_args, ...) +ZEND_ATTRIBUTE_NONNULL ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int num_args, ...) { uint32_t idx; va_list args; @@ -2187,8 +2185,7 @@ ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t ap } } - -ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func) { uint32_t idx; int result; @@ -2235,8 +2232,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t } } - -ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, const HashTable *source, copy_ctor_func_t pCopyConstructor) +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, const HashTable *source, copy_ctor_func_t pCopyConstructor) { uint32_t idx; zval *new_entry, *data; @@ -2282,8 +2278,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, const HashTable *s } } - -static zend_always_inline bool zend_array_dup_value(const HashTable *source, zval *data, zval *dest, bool packed, bool with_holes) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_array_dup_value(const HashTable *source, zval *data, zval *dest, bool packed, bool with_holes) { if (with_holes) { if (!packed && Z_TYPE_INFO_P(data) == IS_INDIRECT) { @@ -2320,7 +2315,7 @@ static zend_always_inline bool zend_array_dup_value(const HashTable *source, zva return 1; } -static zend_always_inline bool zend_array_dup_element(const HashTable *source, HashTable *target, uint32_t idx, Bucket *p, Bucket *q, bool packed, bool static_keys, bool with_holes) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_array_dup_element(const HashTable *source, HashTable *target, uint32_t idx, Bucket *p, Bucket *q, bool packed, bool static_keys, bool with_holes) { if (!zend_array_dup_value(source, &p->val, &q->val, packed, with_holes)) { return 0; @@ -2361,7 +2356,7 @@ static void zend_array_dup_ht_iterators(const HashTable *source, HashTable *targ } } -static zend_always_inline void zend_array_dup_packed_elements(const HashTable *source, HashTable *target, bool with_holes) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_array_dup_packed_elements(const HashTable *source, HashTable *target, bool with_holes) { zval *p = source->arPacked; zval *q = target->arPacked; @@ -2522,7 +2517,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(const HashTable *source) return target; } -ZEND_API HashTable* zend_array_to_list(const HashTable *source) +ZEND_ATTRIBUTE_NONNULL ZEND_API HashTable* zend_array_to_list(const HashTable *source) { HashTable *result = _zend_new_array(zend_hash_num_elements(source)); zend_hash_real_init_packed(result); @@ -2664,7 +2659,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_merge_ex(HashTable *target, const HashTabl /* Returns the hash table data if found and NULL if not. */ -ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key) { Bucket *p; @@ -2675,7 +2670,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *ke return p ? &p->val : NULL; } -ZEND_API zval* ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, const zend_string *key) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, const zend_string *key) { Bucket *p; @@ -2685,7 +2680,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, cons return p ? &p->val : NULL; } -ZEND_API zval* ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *str, size_t len) { zend_ulong h; Bucket *p; @@ -2697,7 +2692,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char return p ? &p->val : NULL; } -ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h) { Bucket *p; @@ -2718,7 +2713,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulon return p ? &p->val : NULL; } -ZEND_API zval* ZEND_FASTCALL _zend_hash_index_find(const HashTable *ht, zend_ulong h) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL _zend_hash_index_find(const HashTable *ht, zend_ulong h) { Bucket *p; @@ -2729,7 +2724,7 @@ ZEND_API zval* ZEND_FASTCALL _zend_hash_index_find(const HashTable *ht, zend_ulo return p ? &p->val : NULL; } -ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(const HashTable *ht, HashPosition *pos) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(const HashTable *ht, HashPosition *pos) { IS_CONSISTENT(ht); HT_ASSERT(ht, &ht->nInternalPointer != pos || GC_REFCOUNT(ht) == 1); @@ -2740,7 +2735,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(const HashTable /* This function will be extremely optimized by remembering * the end of the list */ -ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(const HashTable *ht, HashPosition *pos) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(const HashTable *ht, HashPosition *pos) { uint32_t idx; @@ -2768,8 +2763,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(const HashTable *h *pos = ht->nNumUsed; } - -ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(const HashTable *ht, HashPosition *pos) +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(const HashTable *ht, HashPosition *pos) { uint32_t idx; @@ -2808,7 +2802,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(const HashTable *ht } } -ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable *ht, HashPosition *pos) +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable *ht, HashPosition *pos) { uint32_t idx = *pos; @@ -2840,9 +2834,7 @@ ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable * } } - -/* This function should be made binary safe */ -ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, const HashPosition *pos) +ZEND_ATTRIBUTE_NONNULL_ARGS(1) ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, const HashPosition *pos) { uint32_t idx; Bucket *p; @@ -2866,7 +2858,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zen return HASH_KEY_NON_EXISTENT; } -ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, const HashPosition *pos) +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, const HashPosition *pos) { uint32_t idx; Bucket *p; @@ -2889,7 +2881,7 @@ ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *h } } -ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos) +ZEND_ATTRIBUTE_NONNULL ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos) { uint32_t idx; Bucket *p; @@ -2910,8 +2902,7 @@ ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht return HASH_KEY_NON_EXISTENT; } - -ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(const HashTable *ht, const HashPosition *pos) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(const HashTable *ht, const HashPosition *pos) { uint32_t idx; Bucket *p; @@ -2929,7 +2920,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(const HashTable *ht, } } -ZEND_API void zend_hash_bucket_swap(Bucket *p, Bucket *q) +ZEND_ATTRIBUTE_NONNULL ZEND_API void zend_hash_bucket_swap(Bucket *p, Bucket *q) { zval val; zend_ulong h; @@ -2948,7 +2939,7 @@ ZEND_API void zend_hash_bucket_swap(Bucket *p, Bucket *q) q->key = key; } -ZEND_API void zend_hash_bucket_renum_swap(Bucket *p, Bucket *q) +ZEND_ATTRIBUTE_NONNULL ZEND_API void zend_hash_bucket_renum_swap(Bucket *p, Bucket *q) { zval val; @@ -2957,7 +2948,7 @@ ZEND_API void zend_hash_bucket_renum_swap(Bucket *p, Bucket *q) q->val = val; } -ZEND_API void zend_hash_bucket_packed_swap(Bucket *p, Bucket *q) +ZEND_ATTRIBUTE_NONNULL ZEND_API void zend_hash_bucket_packed_swap(Bucket *p, Bucket *q) { zval val; zend_ulong h; @@ -3091,7 +3082,7 @@ ZEND_API void ZEND_FASTCALL zend_array_sort_ex(HashTable *ht, sort_func_t sort, } } -static zend_always_inline int zend_hash_compare_impl(const HashTable *ht1, const HashTable *ht2, compare_func_t compar, bool ordered) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline int zend_hash_compare_impl(const HashTable *ht1, const HashTable *ht2, compare_func_t compar, bool ordered) { uint32_t idx1, idx2; zend_string *key1, *key2; zend_ulong h1, h2; @@ -3193,7 +3184,7 @@ static zend_always_inline int zend_hash_compare_impl(const HashTable *ht1, const return 0; } -ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, bool ordered) +ZEND_ATTRIBUTE_NONNULL ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, bool ordered) { int result; IS_CONSISTENT(ht1); @@ -3219,8 +3210,7 @@ ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t co return result; } - -ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag) +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag) { uint32_t idx; zval *res; @@ -3287,7 +3277,7 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_ return res; } -ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx) +ZEND_ATTRIBUTE_NONNULL ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx) { const char *tmp = key; @@ -3330,7 +3320,7 @@ ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t * and converts it to a "proptable" (contains only string keys). * If the symtable didn't need duplicating, its refcount is incremented. */ -ZEND_API HashTable* ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht) +ZEND_ATTRIBUTE_NONNULL ZEND_API HashTable* ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht) { zend_ulong num_key; zend_string *str_key; @@ -3383,7 +3373,7 @@ ZEND_API HashTable* ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht) * a "symtable" (contains integer and non-numeric string keys). * If the proptable didn't need duplicating, its refcount is incremented. */ -ZEND_API HashTable* ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, bool always_duplicate) +ZEND_ATTRIBUTE_NONNULL ZEND_API HashTable* ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, bool always_duplicate) { zend_ulong num_key; zend_string *str_key; diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h index b2aaecce0d27c..e680cc671e88e 100644 --- a/Zend/zend_hash.h +++ b/Zend/zend_hash.h @@ -21,6 +21,7 @@ #ifndef ZEND_HASH_H #define ZEND_HASH_H +#include "zend_portability.h" #include "zend_types.h" #include "zend_gc.h" #include "zend_string.h" @@ -103,46 +104,46 @@ BEGIN_EXTERN_C() /* startup/shutdown */ ZEND_API void ZEND_FASTCALL _zend_hash_init(HashTable *ht, uint32_t nSize, dtor_func_t pDestructor, bool persistent); -ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht); -ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_destroy(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_clean(HashTable *ht); #define zend_hash_init(ht, nSize, pHashFunction, pDestructor, persistent) \ _zend_hash_init((ht), (nSize), (pDestructor), (persistent)) -ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, bool packed); -ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht); -ZEND_API void ZEND_FASTCALL zend_hash_real_init_mixed(HashTable *ht); -ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht); -ZEND_API void ZEND_FASTCALL zend_hash_to_packed(HashTable *ht); -ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool packed); -ZEND_API void ZEND_FASTCALL zend_hash_discard(HashTable *ht, uint32_t nNumUsed); -ZEND_API void ZEND_FASTCALL zend_hash_packed_grow(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_real_init(HashTable *ht, bool packed); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_real_init_packed(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_real_init_mixed(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_packed_to_hash(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_to_packed(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_extend(HashTable *ht, uint32_t nSize, bool packed); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_discard(HashTable *ht, uint32_t nNumUsed); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_packed_grow(HashTable *ht); /* additions/updates/changes */ -ZEND_API zval* ZEND_FASTCALL zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag); -ZEND_API zval* ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key,zval *pData); -ZEND_API zval* ZEND_FASTCALL zend_hash_update_ind(HashTable *ht, zend_string *key,zval *pData); -ZEND_API zval* ZEND_FASTCALL zend_hash_add(HashTable *ht, zend_string *key,zval *pData); -ZEND_API zval* ZEND_FASTCALL zend_hash_add_new(HashTable *ht, zend_string *key,zval *pData); - -ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_or_update(HashTable *ht, const char *key, size_t len, zval *pData, uint32_t flag); -ZEND_API zval* ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *key, size_t len, zval *pData); -ZEND_API zval* ZEND_FASTCALL zend_hash_str_update_ind(HashTable *ht, const char *key, size_t len, zval *pData); -ZEND_API zval* ZEND_FASTCALL zend_hash_str_add(HashTable *ht, const char *key, size_t len, zval *pData); -ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_new(HashTable *ht, const char *key, size_t len, zval *pData); - -ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_or_update(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag); -ZEND_API zval* ZEND_FASTCALL zend_hash_index_add(HashTable *ht, zend_ulong h, zval *pData); -ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData); -ZEND_API zval* ZEND_FASTCALL zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData); -ZEND_API zval* ZEND_FASTCALL zend_hash_next_index_insert(HashTable *ht, zval *pData); -ZEND_API zval* ZEND_FASTCALL zend_hash_next_index_insert_new(HashTable *ht, zval *pData); - -ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h); -ZEND_API zval* ZEND_FASTCALL zend_hash_add_empty_element(HashTable *ht, zend_string *key); -ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_empty_element(HashTable *ht, const char *key, size_t len); - -ZEND_API zval* ZEND_FASTCALL zend_hash_set_bucket_key(HashTable *ht, Bucket *p, zend_string *key); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_add_or_update(HashTable *ht, zend_string *key, zval *pData, uint32_t flag); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_update(HashTable *ht, zend_string *key,zval *pData); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_update_ind(HashTable *ht, zend_string *key,zval *pData); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_add(HashTable *ht, zend_string *key,zval *pData); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_add_new(HashTable *ht, zend_string *key,zval *pData); + +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_or_update(HashTable *ht, const char *key, size_t len, zval *pData, uint32_t flag); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *key, size_t len, zval *pData); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_update_ind(HashTable *ht, const char *key, size_t len, zval *pData); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_add(HashTable *ht, const char *key, size_t len, zval *pData); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_new(HashTable *ht, const char *key, size_t len, zval *pData); + +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_or_update(HashTable *ht, zend_ulong h, zval *pData, uint32_t flag); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_add(HashTable *ht, zend_ulong h, zval *pData); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_new(HashTable *ht, zend_ulong h, zval *pData); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_update(HashTable *ht, zend_ulong h, zval *pData); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_next_index_insert(HashTable *ht, zval *pData); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_next_index_insert_new(HashTable *ht, zval *pData); + +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_add_empty_element(HashTable *ht, zend_ulong h); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_add_empty_element(HashTable *ht, zend_string *key); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_add_empty_element(HashTable *ht, const char *key, size_t len); + +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_set_bucket_key(HashTable *ht, Bucket *p, zend_string *key); #define ZEND_HASH_APPLY_KEEP 0 #define ZEND_HASH_APPLY_REMOVE 1<<0 @@ -152,11 +153,11 @@ typedef int (*apply_func_t)(zval *pDest); typedef int (*apply_func_arg_t)(zval *pDest, void *argument); typedef int (*apply_func_args_t)(zval *pDest, int num_args, va_list args, zend_hash_key *hash_key); -ZEND_API void ZEND_FASTCALL zend_hash_graceful_destroy(HashTable *ht); -ZEND_API void ZEND_FASTCALL zend_hash_graceful_reverse_destroy(HashTable *ht); -ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_func); -ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *); -ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int, ...); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_graceful_destroy(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_graceful_reverse_destroy(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_apply(HashTable *ht, apply_func_t apply_func); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_apply_with_argument(HashTable *ht, apply_func_arg_t apply_func, void *); +ZEND_ATTRIBUTE_NONNULL ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t apply_func, int, ...); /* This function should be used with special care (in other words, * it should usually not be used). When used with the ZEND_HASH_APPLY_STOP @@ -164,28 +165,28 @@ ZEND_API void zend_hash_apply_with_arguments(HashTable *ht, apply_func_args_t ap * Also, it does not provide the same kind of reentrancy protection that * the standard apply functions do. */ -ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_reverse_apply(HashTable *ht, apply_func_t apply_func); /* Deletes */ -ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key); -ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key); -ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len); -ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len); -ZEND_API zend_result ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h); -ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p); -ZEND_API void ZEND_FASTCALL zend_hash_packed_del_val(HashTable *ht, zval *zv); +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_del(HashTable *ht, zend_string *key); +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_del_ind(HashTable *ht, zend_string *key); +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del(HashTable *ht, const char *key, size_t len); +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_str_del_ind(HashTable *ht, const char *key, size_t len); +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_index_del(HashTable *ht, zend_ulong h); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_del_bucket(HashTable *ht, Bucket *p); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_packed_del_val(HashTable *ht, zval *zv); /* Data retrieval */ -ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key); -ZEND_API zval* ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *key, size_t len); -ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h); -ZEND_API zval* ZEND_FASTCALL _zend_hash_index_find(const HashTable *ht, zend_ulong h); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_find(const HashTable *ht, zend_string *key); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_str_find(const HashTable *ht, const char *key, size_t len); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_find(const HashTable *ht, zend_ulong h); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL _zend_hash_index_find(const HashTable *ht, zend_ulong h); /* The same as zend_hash_find(), but hash value of the key must be already calculated. */ -ZEND_API zval* ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, const zend_string *key); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_find_known_hash(const HashTable *ht, const zend_string *key); -static zend_always_inline zval *zend_hash_find_ex(const HashTable *ht, zend_string *key, bool known_hash) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_hash_find_ex(const HashTable *ht, zend_string *key, bool known_hash) { if (known_hash) { return zend_hash_find_known_hash(ht, key); @@ -214,8 +215,8 @@ static zend_always_inline zval *zend_hash_find_ex(const HashTable *ht, zend_stri /* Find or add NULL, if doesn't exist */ -ZEND_API zval* ZEND_FASTCALL zend_hash_lookup(HashTable *ht, zend_string *key); -ZEND_API zval* ZEND_FASTCALL zend_hash_index_lookup(HashTable *ht, zend_ulong h); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_lookup(HashTable *ht, zend_string *key); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_index_lookup(HashTable *ht, zend_ulong h); #define ZEND_HASH_INDEX_LOOKUP(_ht, _h, _ret) do { \ if (EXPECTED(HT_IS_PACKED(_ht))) { \ @@ -230,95 +231,95 @@ ZEND_API zval* ZEND_FASTCALL zend_hash_index_lookup(HashTable *ht, zend_ulong h) } while (0) /* Misc */ -static zend_always_inline bool zend_hash_exists(const HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_hash_exists(const HashTable *ht, zend_string *key) { return zend_hash_find(ht, key) != NULL; } -static zend_always_inline bool zend_hash_str_exists(const HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_hash_str_exists(const HashTable *ht, const char *str, size_t len) { return zend_hash_str_find(ht, str, len) != NULL; } -static zend_always_inline bool zend_hash_index_exists(const HashTable *ht, zend_ulong h) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_hash_index_exists(const HashTable *ht, zend_ulong h) { return zend_hash_index_find(ht, h) != NULL; } /* traversing */ -ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos_ex(const HashTable *ht, HashPosition pos); -ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos(const HashTable *ht); - -ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(const HashTable *ht, HashPosition *pos); -ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable *ht, HashPosition *pos); -ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, const HashPosition *pos); -ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, const HashPosition *pos); -ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos); -ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(const HashTable *ht, const HashPosition *pos); -ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(const HashTable *ht, HashPosition *pos); -ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(const HashTable *ht, HashPosition *pos); - -static zend_always_inline zend_result zend_hash_has_more_elements_ex(const HashTable *ht, const HashPosition *pos) { +ZEND_ATTRIBUTE_NONNULL ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos_ex(const HashTable *ht, HashPosition pos); +ZEND_ATTRIBUTE_NONNULL ZEND_API HashPosition ZEND_FASTCALL zend_hash_get_current_pos(const HashTable *ht); + +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_move_forward_ex(const HashTable *ht, HashPosition *pos); +ZEND_ATTRIBUTE_NONNULL ZEND_API zend_result ZEND_FASTCALL zend_hash_move_backwards_ex(const HashTable *ht, HashPosition *pos); +ZEND_ATTRIBUTE_NONNULL_ARGS(1) ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, zend_ulong *num_index, const HashPosition *pos); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, const HashPosition *pos); +ZEND_ATTRIBUTE_NONNULL ZEND_API int ZEND_FASTCALL zend_hash_get_current_key_type_ex(const HashTable *ht, const HashPosition *pos); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_get_current_data_ex(const HashTable *ht, const HashPosition *pos); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_reset_ex(const HashTable *ht, HashPosition *pos); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_hash_internal_pointer_end_ex(const HashTable *ht, HashPosition *pos); + +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zend_result zend_hash_has_more_elements_ex(const HashTable *ht, const HashPosition *pos) { return (zend_hash_get_current_key_type_ex(ht, pos) == HASH_KEY_NON_EXISTENT ? FAILURE : SUCCESS); } -static zend_always_inline zend_result zend_hash_has_more_elements(const HashTable *ht) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zend_result zend_hash_has_more_elements(const HashTable *ht) { return zend_hash_has_more_elements_ex(ht, &ht->nInternalPointer); } -static zend_always_inline zend_result zend_hash_move_forward(HashTable *ht) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zend_result zend_hash_move_forward(HashTable *ht) { return zend_hash_move_forward_ex(ht, &ht->nInternalPointer); } -static zend_always_inline zend_result zend_hash_move_backwards(HashTable *ht) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zend_result zend_hash_move_backwards(HashTable *ht) { return zend_hash_move_backwards_ex(ht, &ht->nInternalPointer); } -static zend_always_inline int zend_hash_get_current_key(const HashTable *ht, zend_string **str_index, zend_ulong *num_index) { +ZEND_ATTRIBUTE_NONNULL_ARGS(1) static zend_always_inline int zend_hash_get_current_key(const HashTable *ht, zend_string **str_index, zend_ulong *num_index) { return zend_hash_get_current_key_ex(ht, str_index, num_index, &ht->nInternalPointer); } -static zend_always_inline void zend_hash_get_current_key_zval(const HashTable *ht, zval *key) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_hash_get_current_key_zval(const HashTable *ht, zval *key) { zend_hash_get_current_key_zval_ex(ht, key, &ht->nInternalPointer); } -static zend_always_inline int zend_hash_get_current_key_type(const HashTable *ht) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline int zend_hash_get_current_key_type(const HashTable *ht) { return zend_hash_get_current_key_type_ex(ht, &ht->nInternalPointer); } -static zend_always_inline zval* zend_hash_get_current_data(const HashTable *ht) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval* zend_hash_get_current_data(const HashTable *ht) { return zend_hash_get_current_data_ex(ht, &ht->nInternalPointer); } -static zend_always_inline void zend_hash_internal_pointer_reset(HashTable *ht) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_hash_internal_pointer_reset(HashTable *ht) { zend_hash_internal_pointer_reset_ex(ht, &ht->nInternalPointer); } -static zend_always_inline void zend_hash_internal_pointer_end(HashTable *ht) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_hash_internal_pointer_end(HashTable *ht) { zend_hash_internal_pointer_end_ex(ht, &ht->nInternalPointer); } /* Copying, merging and sorting */ -ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, const HashTable *source, copy_ctor_func_t pCopyConstructor); +ZEND_ATTRIBUTE_NONNULL_ARGS(1, 2) ZEND_API void ZEND_FASTCALL zend_hash_copy(HashTable *target, const HashTable *source, copy_ctor_func_t pCopyConstructor); ZEND_API void ZEND_FASTCALL zend_hash_merge(HashTable *target, const HashTable *source, copy_ctor_func_t pCopyConstructor, bool overwrite); ZEND_API void ZEND_FASTCALL zend_hash_merge_ex(HashTable *target, const HashTable *source, copy_ctor_func_t pCopyConstructor, merge_checker_func_t pMergeSource, void *pParam); -ZEND_API void zend_hash_bucket_swap(Bucket *p, Bucket *q); -ZEND_API void zend_hash_bucket_renum_swap(Bucket *p, Bucket *q); -ZEND_API void zend_hash_bucket_packed_swap(Bucket *p, Bucket *q); +ZEND_ATTRIBUTE_NONNULL ZEND_API void zend_hash_bucket_swap(Bucket *p, Bucket *q); +ZEND_ATTRIBUTE_NONNULL ZEND_API void zend_hash_bucket_renum_swap(Bucket *p, Bucket *q); +ZEND_ATTRIBUTE_NONNULL ZEND_API void zend_hash_bucket_packed_swap(Bucket *p, Bucket *q); typedef int (*bucket_compare_func_t)(Bucket *a, Bucket *b); -ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, bool ordered); +ZEND_ATTRIBUTE_NONNULL ZEND_API int zend_hash_compare(HashTable *ht1, HashTable *ht2, compare_func_t compar, bool ordered); ZEND_API void ZEND_FASTCALL zend_hash_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber); ZEND_API void ZEND_FASTCALL zend_array_sort_ex(HashTable *ht, sort_func_t sort_func, bucket_compare_func_t compare_func, bool renumber); -ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag); +ZEND_ATTRIBUTE_NONNULL ZEND_API zval* ZEND_FASTCALL zend_hash_minmax(const HashTable *ht, compare_func_t compar, uint32_t flag); -static zend_always_inline void ZEND_FASTCALL zend_hash_sort(HashTable *ht, bucket_compare_func_t compare_func, bool renumber) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void ZEND_FASTCALL zend_hash_sort(HashTable *ht, bucket_compare_func_t compare_func, bool renumber) { zend_hash_sort_ex(ht, zend_sort, compare_func, renumber); } /* Use this variant over zend_hash_sort() when sorting user arrays that may * trigger user code. It will ensure the user code cannot free the array during * sorting. */ -static zend_always_inline void zend_array_sort(HashTable *ht, bucket_compare_func_t compare_func, bool renumber) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_array_sort(HashTable *ht, bucket_compare_func_t compare_func, bool renumber) { zend_array_sort_ex(ht, zend_sort, compare_func, renumber); } -static zend_always_inline uint32_t zend_hash_num_elements(const HashTable *ht) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline uint32_t zend_hash_num_elements(const HashTable *ht) { return ht->nNumOfElements; } -static zend_always_inline zend_long zend_hash_next_free_element(const HashTable *ht) { +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zend_long zend_hash_next_free_element(const HashTable *ht) { return ht->nNextFreeElement; } @@ -342,26 +343,26 @@ ZEND_API void ZEND_FASTCALL zend_hash_rehash(HashTable *ht); ZEND_API HashTable* ZEND_FASTCALL _zend_new_array_0(void); ZEND_API HashTable* ZEND_FASTCALL _zend_new_array(uint32_t size); -ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(const zval *val1, const zval *val2); -ZEND_API uint32_t zend_array_count(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API HashTable* ZEND_FASTCALL zend_new_pair(const zval *val1, const zval *val2); +ZEND_ATTRIBUTE_NONNULL ZEND_API uint32_t zend_array_count(HashTable *ht); ZEND_API HashTable* ZEND_FASTCALL zend_array_dup(const HashTable *source); -ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht); -ZEND_API HashTable* zend_array_to_list(const HashTable *source); -ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht); -ZEND_API HashTable* ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht); -ZEND_API HashTable* ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, bool always_duplicate); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API HashTable* zend_array_to_list(const HashTable *source); +ZEND_ATTRIBUTE_NONNULL ZEND_API void ZEND_FASTCALL zend_symtable_clean(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API HashTable* ZEND_FASTCALL zend_symtable_to_proptable(HashTable *ht); +ZEND_ATTRIBUTE_NONNULL ZEND_API HashTable* ZEND_FASTCALL zend_proptable_to_symtable(HashTable *ht, bool always_duplicate); -ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx); +ZEND_ATTRIBUTE_NONNULL ZEND_API bool ZEND_FASTCALL _zend_handle_numeric_str_ex(const char *key, size_t length, zend_ulong *idx); -ZEND_API uint32_t ZEND_FASTCALL zend_hash_iterator_add(HashTable *ht, HashPosition pos); +ZEND_ATTRIBUTE_NONNULL ZEND_API uint32_t ZEND_FASTCALL zend_hash_iterator_add(HashTable *ht, HashPosition pos); ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos(uint32_t idx, HashTable *ht); -ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos_ex(uint32_t idx, zval *array); +ZEND_ATTRIBUTE_NONNULL ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterator_pos_ex(uint32_t idx, zval *array); ZEND_API void ZEND_FASTCALL zend_hash_iterator_del(uint32_t idx); ZEND_API HashPosition ZEND_FASTCALL zend_hash_iterators_lower_pos(const HashTable *ht, HashPosition start); ZEND_API void ZEND_FASTCALL _zend_hash_iterators_update(const HashTable *ht, HashPosition from, HashPosition to); ZEND_API void ZEND_FASTCALL zend_hash_iterators_advance(const HashTable *ht, HashPosition step); -static zend_always_inline void zend_hash_iterators_update(const HashTable *ht, HashPosition from, HashPosition to) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_hash_iterators_update(const HashTable *ht, HashPosition from, HashPosition to) { if (UNEXPECTED(HT_HAS_ITERATORS(ht))) { _zend_hash_iterators_update(ht, from, to); @@ -369,7 +370,7 @@ static zend_always_inline void zend_hash_iterators_update(const HashTable *ht, H } /* For regular arrays (non-persistent, storing zvals). */ -static zend_always_inline void zend_array_release(zend_array *array) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_array_release(zend_array *array) { if (!(GC_FLAGS(array) & IS_ARRAY_IMMUTABLE)) { if (GC_DELREF(array) == 0) { @@ -379,7 +380,7 @@ static zend_always_inline void zend_array_release(zend_array *array) } /* For general hashes (possibly persistent, storing any kind of value). */ -static zend_always_inline void zend_hash_release(zend_array *array) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void zend_hash_release(zend_array *array) { if (!(GC_FLAGS(array) & IS_ARRAY_IMMUTABLE)) { if (GC_DELREF(array) == 0) { @@ -397,7 +398,7 @@ END_EXTERN_C() #define ZEND_INIT_SYMTABLE_EX(ht, n, persistent) \ zend_hash_init(ht, n, NULL, ZVAL_PTR_DTOR, persistent) -static zend_always_inline bool _zend_handle_numeric_str(const char *key, size_t length, zend_ulong *idx) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool _zend_handle_numeric_str(const char *key, size_t length, zend_ulong *idx) { const char *tmp = key; @@ -421,8 +422,7 @@ static zend_always_inline bool _zend_handle_numeric_str(const char *key, size_t #define ZEND_HANDLE_NUMERIC(key, idx) \ ZEND_HANDLE_NUMERIC_STR(ZSTR_VAL(key), ZSTR_LEN(key), idx) - -static zend_always_inline zval *zend_hash_find_ind(const HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_hash_find_ind(const HashTable *ht, zend_string *key) { zval *zv; @@ -431,8 +431,7 @@ static zend_always_inline zval *zend_hash_find_ind(const HashTable *ht, zend_str ((Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF) ? Z_INDIRECT_P(zv) : NULL) : zv; } - -static zend_always_inline zval *zend_hash_find_ex_ind(const HashTable *ht, zend_string *key, bool known_hash) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_hash_find_ex_ind(const HashTable *ht, zend_string *key, bool known_hash) { zval *zv; @@ -441,8 +440,7 @@ static zend_always_inline zval *zend_hash_find_ex_ind(const HashTable *ht, zend_ ((Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF) ? Z_INDIRECT_P(zv) : NULL) : zv; } - -static zend_always_inline bool zend_hash_exists_ind(const HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_hash_exists_ind(const HashTable *ht, zend_string *key) { zval *zv; @@ -451,8 +449,7 @@ static zend_always_inline bool zend_hash_exists_ind(const HashTable *ht, zend_st Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF); } - -static zend_always_inline zval *zend_hash_str_find_ind(const HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_hash_str_find_ind(const HashTable *ht, const char *str, size_t len) { zval *zv; @@ -461,8 +458,7 @@ static zend_always_inline zval *zend_hash_str_find_ind(const HashTable *ht, cons ((Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF) ? Z_INDIRECT_P(zv) : NULL) : zv; } - -static zend_always_inline bool zend_hash_str_exists_ind(const HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_hash_str_exists_ind(const HashTable *ht, const char *str, size_t len) { zval *zv; @@ -471,7 +467,7 @@ static zend_always_inline bool zend_hash_str_exists_ind(const HashTable *ht, con Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF); } -static zend_always_inline zval *zend_symtable_add_new(HashTable *ht, zend_string *key, zval *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_symtable_add_new(HashTable *ht, zend_string *key, zval *pData) { zend_ulong idx; @@ -482,7 +478,7 @@ static zend_always_inline zval *zend_symtable_add_new(HashTable *ht, zend_string } } -static zend_always_inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData) { zend_ulong idx; @@ -493,8 +489,7 @@ static zend_always_inline zval *zend_symtable_update(HashTable *ht, zend_string } } - -static zend_always_inline zval *zend_symtable_update_ind(HashTable *ht, zend_string *key, zval *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_symtable_update_ind(HashTable *ht, zend_string *key, zval *pData) { zend_ulong idx; @@ -505,8 +500,7 @@ static zend_always_inline zval *zend_symtable_update_ind(HashTable *ht, zend_str } } - -static zend_always_inline zend_result zend_symtable_del(HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zend_result zend_symtable_del(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -517,8 +511,7 @@ static zend_always_inline zend_result zend_symtable_del(HashTable *ht, zend_stri } } - -static zend_always_inline zend_result zend_symtable_del_ind(HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zend_result zend_symtable_del_ind(HashTable *ht, zend_string *key) { zend_ulong idx; @@ -529,8 +522,7 @@ static zend_always_inline zend_result zend_symtable_del_ind(HashTable *ht, zend_ } } - -static zend_always_inline zval *zend_symtable_find(const HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_symtable_find(const HashTable *ht, zend_string *key) { zend_ulong idx; @@ -541,8 +533,7 @@ static zend_always_inline zval *zend_symtable_find(const HashTable *ht, zend_str } } - -static zend_always_inline zval *zend_symtable_find_ind(const HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_symtable_find_ind(const HashTable *ht, zend_string *key) { zend_ulong idx; @@ -553,8 +544,7 @@ static zend_always_inline zval *zend_symtable_find_ind(const HashTable *ht, zend } } - -static zend_always_inline bool zend_symtable_exists(const HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_symtable_exists(const HashTable *ht, zend_string *key) { zend_ulong idx; @@ -565,8 +555,7 @@ static zend_always_inline bool zend_symtable_exists(const HashTable *ht, zend_st } } - -static zend_always_inline bool zend_symtable_exists_ind(const HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_symtable_exists_ind(const HashTable *ht, zend_string *key) { zend_ulong idx; @@ -577,8 +566,7 @@ static zend_always_inline bool zend_symtable_exists_ind(const HashTable *ht, zen } } - -static zend_always_inline zval *zend_symtable_str_update(HashTable *ht, const char *str, size_t len, zval *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_symtable_str_update(HashTable *ht, const char *str, size_t len, zval *pData) { zend_ulong idx; @@ -589,8 +577,7 @@ static zend_always_inline zval *zend_symtable_str_update(HashTable *ht, const ch } } - -static zend_always_inline zval *zend_symtable_str_update_ind(HashTable *ht, const char *str, size_t len, zval *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_symtable_str_update_ind(HashTable *ht, const char *str, size_t len, zval *pData) { zend_ulong idx; @@ -601,8 +588,7 @@ static zend_always_inline zval *zend_symtable_str_update_ind(HashTable *ht, cons } } - -static zend_always_inline zend_result zend_symtable_str_del(HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zend_result zend_symtable_str_del(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -613,8 +599,7 @@ static zend_always_inline zend_result zend_symtable_str_del(HashTable *ht, const } } - -static zend_always_inline zend_result zend_symtable_str_del_ind(HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zend_result zend_symtable_str_del_ind(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -625,8 +610,7 @@ static zend_always_inline zend_result zend_symtable_str_del_ind(HashTable *ht, c } } - -static zend_always_inline zval *zend_symtable_str_find(HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_symtable_str_find(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -637,8 +621,7 @@ static zend_always_inline zval *zend_symtable_str_find(HashTable *ht, const char } } - -static zend_always_inline bool zend_symtable_str_exists(HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_symtable_str_exists(HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -649,7 +632,7 @@ static zend_always_inline bool zend_symtable_str_exists(HashTable *ht, const cha } } -static zend_always_inline void *zend_hash_add_ptr(HashTable *ht, zend_string *key, void *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_add_ptr(HashTable *ht, zend_string *key, void *pData) { zval tmp, *zv; @@ -663,7 +646,7 @@ static zend_always_inline void *zend_hash_add_ptr(HashTable *ht, zend_string *ke } } -static zend_always_inline void *zend_hash_add_new_ptr(HashTable *ht, zend_string *key, void *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_add_new_ptr(HashTable *ht, zend_string *key, void *pData) { zval tmp, *zv; @@ -677,7 +660,7 @@ static zend_always_inline void *zend_hash_add_new_ptr(HashTable *ht, zend_string } } -static zend_always_inline void *zend_hash_str_add_ptr(HashTable *ht, const char *str, size_t len, void *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_str_add_ptr(HashTable *ht, const char *str, size_t len, void *pData) { zval tmp, *zv; @@ -691,7 +674,7 @@ static zend_always_inline void *zend_hash_str_add_ptr(HashTable *ht, const char } } -static zend_always_inline void *zend_hash_str_add_new_ptr(HashTable *ht, const char *str, size_t len, void *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_str_add_new_ptr(HashTable *ht, const char *str, size_t len, void *pData) { zval tmp, *zv; @@ -705,7 +688,7 @@ static zend_always_inline void *zend_hash_str_add_new_ptr(HashTable *ht, const c } } -static zend_always_inline void *zend_hash_update_ptr(HashTable *ht, zend_string *key, void *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_update_ptr(HashTable *ht, zend_string *key, void *pData) { zval tmp, *zv; @@ -715,7 +698,7 @@ static zend_always_inline void *zend_hash_update_ptr(HashTable *ht, zend_string return Z_PTR_P(zv); } -static zend_always_inline void *zend_hash_str_update_ptr(HashTable *ht, const char *str, size_t len, void *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_str_update_ptr(HashTable *ht, const char *str, size_t len, void *pData) { zval tmp, *zv; @@ -725,7 +708,7 @@ static zend_always_inline void *zend_hash_str_update_ptr(HashTable *ht, const ch return Z_PTR_P(zv); } -static zend_always_inline void *zend_hash_add_mem(HashTable *ht, zend_string *key, void *pData, size_t size) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_add_mem(HashTable *ht, zend_string *key, void *pData, size_t size) { zval tmp, *zv; @@ -738,7 +721,7 @@ static zend_always_inline void *zend_hash_add_mem(HashTable *ht, zend_string *ke return NULL; } -static zend_always_inline void *zend_hash_add_new_mem(HashTable *ht, zend_string *key, void *pData, size_t size) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_add_new_mem(HashTable *ht, zend_string *key, void *pData, size_t size) { zval tmp, *zv; @@ -751,7 +734,7 @@ static zend_always_inline void *zend_hash_add_new_mem(HashTable *ht, zend_string return NULL; } -static zend_always_inline void *zend_hash_str_add_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_str_add_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size) { zval tmp, *zv; @@ -764,7 +747,7 @@ static zend_always_inline void *zend_hash_str_add_mem(HashTable *ht, const char return NULL; } -static zend_always_inline void *zend_hash_str_add_new_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_str_add_new_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size) { zval tmp, *zv; @@ -777,7 +760,7 @@ static zend_always_inline void *zend_hash_str_add_new_mem(HashTable *ht, const c return NULL; } -static zend_always_inline void *zend_hash_update_mem(HashTable *ht, zend_string *key, void *pData, size_t size) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_update_mem(HashTable *ht, zend_string *key, void *pData, size_t size) { void *p; @@ -786,7 +769,7 @@ static zend_always_inline void *zend_hash_update_mem(HashTable *ht, zend_string return zend_hash_update_ptr(ht, key, p); } -static zend_always_inline void *zend_hash_str_update_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_str_update_mem(HashTable *ht, const char *str, size_t len, void *pData, size_t size) { void *p; @@ -795,7 +778,7 @@ static zend_always_inline void *zend_hash_str_update_mem(HashTable *ht, const ch return zend_hash_str_update_ptr(ht, str, len, p); } -static zend_always_inline void *zend_hash_index_add_ptr(HashTable *ht, zend_ulong h, void *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_index_add_ptr(HashTable *ht, zend_ulong h, void *pData) { zval tmp, *zv; @@ -804,7 +787,7 @@ static zend_always_inline void *zend_hash_index_add_ptr(HashTable *ht, zend_ulon return zv ? Z_PTR_P(zv) : NULL; } -static zend_always_inline void *zend_hash_index_add_new_ptr(HashTable *ht, zend_ulong h, void *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_index_add_new_ptr(HashTable *ht, zend_ulong h, void *pData) { zval tmp, *zv; @@ -813,7 +796,7 @@ static zend_always_inline void *zend_hash_index_add_new_ptr(HashTable *ht, zend_ return zv ? Z_PTR_P(zv) : NULL; } -static zend_always_inline void *zend_hash_index_update_ptr(HashTable *ht, zend_ulong h, void *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_index_update_ptr(HashTable *ht, zend_ulong h, void *pData) { zval tmp, *zv; @@ -823,7 +806,7 @@ static zend_always_inline void *zend_hash_index_update_ptr(HashTable *ht, zend_u return Z_PTR_P(zv); } -static zend_always_inline void *zend_hash_index_add_mem(HashTable *ht, zend_ulong h, void *pData, size_t size) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_index_add_mem(HashTable *ht, zend_ulong h, void *pData, size_t size) { zval tmp, *zv; @@ -836,7 +819,7 @@ static zend_always_inline void *zend_hash_index_add_mem(HashTable *ht, zend_ulon return NULL; } -static zend_always_inline void *zend_hash_next_index_insert_ptr(HashTable *ht, void *pData) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_next_index_insert_ptr(HashTable *ht, void *pData) { zval tmp, *zv; @@ -850,7 +833,7 @@ static zend_always_inline void *zend_hash_next_index_insert_ptr(HashTable *ht, v } } -static zend_always_inline void *zend_hash_index_update_mem(HashTable *ht, zend_ulong h, void *pData, size_t size) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_index_update_mem(HashTable *ht, zend_ulong h, void *pData, size_t size) { void *p; @@ -859,7 +842,7 @@ static zend_always_inline void *zend_hash_index_update_mem(HashTable *ht, zend_u return zend_hash_index_update_ptr(ht, h, p); } -static zend_always_inline void *zend_hash_next_index_insert_mem(HashTable *ht, void *pData, size_t size) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_next_index_insert_mem(HashTable *ht, void *pData, size_t size) { zval tmp; @@ -873,7 +856,7 @@ static zend_always_inline void *zend_hash_next_index_insert_mem(HashTable *ht, v return p; } -static zend_always_inline void *zend_hash_find_ptr(const HashTable *ht, zend_string *key) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_find_ptr(const HashTable *ht, zend_string *key) { zval *zv; @@ -886,7 +869,7 @@ static zend_always_inline void *zend_hash_find_ptr(const HashTable *ht, zend_str } } -static zend_always_inline void *zend_hash_find_ex_ptr(const HashTable *ht, zend_string *key, bool known_hash) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_find_ex_ptr(const HashTable *ht, zend_string *key, bool known_hash) { zval *zv; @@ -899,7 +882,7 @@ static zend_always_inline void *zend_hash_find_ex_ptr(const HashTable *ht, zend_ } } -static zend_always_inline void *zend_hash_str_find_ptr(const HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_str_find_ptr(const HashTable *ht, const char *str, size_t len) { zval *zv; @@ -916,15 +899,15 @@ BEGIN_EXTERN_C() /* Will lowercase the str; use only if you don't need the lowercased string for * anything else. If you have a lowered string, use zend_hash_str_find_ptr. */ -ZEND_API void *zend_hash_str_find_ptr_lc(const HashTable *ht, const char *str, size_t len); +ZEND_ATTRIBUTE_NONNULL ZEND_API void *zend_hash_str_find_ptr_lc(const HashTable *ht, const char *str, size_t len); /* Will lowercase the str; use only if you don't need the lowercased string for * anything else. If you have a lowered string, use zend_hash_find_ptr. */ -ZEND_API void *zend_hash_find_ptr_lc(const HashTable *ht, zend_string *key); +ZEND_ATTRIBUTE_NONNULL ZEND_API void *zend_hash_find_ptr_lc(const HashTable *ht, zend_string *key); END_EXTERN_C() -static zend_always_inline void *zend_hash_index_find_ptr(const HashTable *ht, zend_ulong h) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_index_find_ptr(const HashTable *ht, zend_ulong h) { zval *zv; @@ -937,7 +920,7 @@ static zend_always_inline void *zend_hash_index_find_ptr(const HashTable *ht, ze } } -static zend_always_inline zval *zend_hash_index_find_deref(const HashTable *ht, zend_ulong h) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_hash_index_find_deref(const HashTable *ht, zend_ulong h) { zval *zv = zend_hash_index_find(ht, h); if (zv) { @@ -946,7 +929,7 @@ static zend_always_inline zval *zend_hash_index_find_deref(const HashTable *ht, return zv; } -static zend_always_inline zval *zend_hash_find_deref(const HashTable *ht, zend_string *str) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_hash_find_deref(const HashTable *ht, zend_string *str) { zval *zv = zend_hash_find(ht, str); if (zv) { @@ -955,7 +938,7 @@ static zend_always_inline zval *zend_hash_find_deref(const HashTable *ht, zend_s return zv; } -static zend_always_inline zval *zend_hash_str_find_deref(const HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *zend_hash_str_find_deref(const HashTable *ht, const char *str, size_t len) { zval *zv = zend_hash_str_find(ht, str, len); if (zv) { @@ -964,7 +947,7 @@ static zend_always_inline zval *zend_hash_str_find_deref(const HashTable *ht, co return zv; } -static zend_always_inline void *zend_symtable_str_find_ptr(const HashTable *ht, const char *str, size_t len) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_symtable_str_find_ptr(const HashTable *ht, const char *str, size_t len) { zend_ulong idx; @@ -975,7 +958,7 @@ static zend_always_inline void *zend_symtable_str_find_ptr(const HashTable *ht, } } -static zend_always_inline void *zend_hash_get_current_data_ptr_ex(const HashTable *ht, const HashPosition *pos) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void *zend_hash_get_current_data_ptr_ex(const HashTable *ht, const HashPosition *pos) { zval *zv; @@ -1585,7 +1568,7 @@ static zend_always_inline void *zend_hash_get_current_data_ptr_ex(const HashTabl } while (0) /* Check if an array is a list */ -static zend_always_inline bool zend_array_is_list(const zend_array *array) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline bool zend_array_is_list(const zend_array *array) { zend_ulong expected_idx = 0; zend_ulong num_idx; @@ -1618,8 +1601,7 @@ static zend_always_inline bool zend_array_is_list(const zend_array *array) return 1; } - -static zend_always_inline zval *_zend_hash_append_ex(HashTable *ht, zend_string *key, zval *zv, bool interned) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *_zend_hash_append_ex(HashTable *ht, zend_string *key, zval *zv, bool interned) { uint32_t idx = ht->nNumUsed++; uint32_t nIndex; @@ -1640,12 +1622,12 @@ static zend_always_inline zval *_zend_hash_append_ex(HashTable *ht, zend_string return &p->val; } -static zend_always_inline zval *_zend_hash_append(HashTable *ht, zend_string *key, zval *zv) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *_zend_hash_append(HashTable *ht, zend_string *key, zval *zv) { return _zend_hash_append_ex(ht, key, zv, 0); } -static zend_always_inline zval *_zend_hash_append_ptr_ex(HashTable *ht, zend_string *key, void *ptr, bool interned) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *_zend_hash_append_ptr_ex(HashTable *ht, zend_string *key, void *ptr, bool interned) { uint32_t idx = ht->nNumUsed++; uint32_t nIndex; @@ -1666,12 +1648,12 @@ static zend_always_inline zval *_zend_hash_append_ptr_ex(HashTable *ht, zend_str return &p->val; } -static zend_always_inline zval *_zend_hash_append_ptr(HashTable *ht, zend_string *key, void *ptr) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline zval *_zend_hash_append_ptr(HashTable *ht, zend_string *key, void *ptr) { return _zend_hash_append_ptr_ex(ht, key, ptr, 0); } -static zend_always_inline void _zend_hash_append_ind(HashTable *ht, zend_string *key, zval *ptr) +ZEND_ATTRIBUTE_NONNULL static zend_always_inline void _zend_hash_append_ind(HashTable *ht, zend_string *key, zval *ptr) { uint32_t idx = ht->nNumUsed++; uint32_t nIndex; diff --git a/ext/bz2/bz2_filter.c b/ext/bz2/bz2_filter.c index 2fbdf9452dad3..535d130ecb0c0 100644 --- a/ext/bz2/bz2_filter.c +++ b/ext/bz2/bz2_filter.c @@ -335,14 +335,15 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi if (filterparams) { zval *tmpzval = NULL; + const HashTable *filter_params_ht = HASH_OF(filterparams); - if (Z_TYPE_P(filterparams) == IS_ARRAY || Z_TYPE_P(filterparams) == IS_OBJECT) { - if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "concatenated", sizeof("concatenated")-1))) { + if (filter_params_ht != NULL) { + if ((tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("concatenated")))) { data->expect_concatenated = zend_is_true(tmpzval); tmpzval = NULL; } - tmpzval = zend_hash_str_find(HASH_OF(filterparams), "small", sizeof("small")-1); + tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("small")); } else { tmpzval = filterparams; } @@ -359,10 +360,11 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi int workFactor = PHP_BZ2_FILTER_DEFAULT_WORKFACTOR; if (filterparams) { - zval *tmpzval; + const HashTable *filter_params_ht = HASH_OF(filterparams); - if (Z_TYPE_P(filterparams) == IS_ARRAY || Z_TYPE_P(filterparams) == IS_OBJECT) { - if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "blocks", sizeof("blocks")-1))) { + if (filter_params_ht != NULL) { + zval *tmpzval; + if ((tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("blocks")))) { /* How much memory to allocate (1 - 9) x 100kb */ zend_long blocks = zval_get_long(tmpzval); if (blocks < 1 || blocks > 9) { @@ -372,7 +374,7 @@ static php_stream_filter *php_bz2_filter_create(const char *filtername, zval *fi } } - if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "work", sizeof("work")-1))) { + if ((tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("work")))) { /* Work Factor (0 - 250) */ zend_long work = zval_get_long(tmpzval); if (work < 0 || work > 250) { diff --git a/ext/dba/dba.c b/ext/dba/dba.c index 086998973e20a..965805e2e8c52 100644 --- a/ext/dba/dba.c +++ b/ext/dba/dba.c @@ -974,11 +974,12 @@ PHP_FUNCTION(dba_close) CHECK_DBA_CONNECTION(connection->info); bool persistent = connection->info->flags & DBA_PERSISTENT; + void *info_ptr = connection->info; dba_close_connection(connection); if (persistent) { - zend_hash_apply_with_argument(&EG(persistent_list), remove_pconnection_from_list, (void *) connection->info); + zend_hash_apply_with_argument(&EG(persistent_list), remove_pconnection_from_list, info_ptr); } } /* }}} */ diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 0c4b12fd73d53..a01b257de4400 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -209,23 +209,29 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha php_url_free(resource); efree(internal_file); - if (context && Z_TYPE(context->options) != IS_UNDEF && (pzoption = zend_hash_str_find(HASH_OF(&context->options), "phar", sizeof("phar")-1)) != NULL) { - pharcontext = HASH_OF(pzoption); - if (idata->internal_file->uncompressed_filesize == 0 - && idata->internal_file->compressed_filesize == 0 - && (pzoption = zend_hash_str_find(pharcontext, "compress", sizeof("compress")-1)) != NULL - && Z_TYPE_P(pzoption) == IS_LONG - && (Z_LVAL_P(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0 - ) { - idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK; - idata->internal_file->flags |= Z_LVAL_P(pzoption); - } - if ((pzoption = zend_hash_str_find(pharcontext, "metadata", sizeof("metadata")-1)) != NULL) { - phar_metadata_tracker_free(&idata->internal_file->metadata_tracker, idata->internal_file->is_persistent); + if (context && !Z_ISUNDEF(context->options)) { + const HashTable *options_ht = HASH_OF(&context->options); + ZEND_ASSERT(options_ht != NULL); + + pzoption = zend_hash_str_find(options_ht, ZEND_STRL("phar")); + if (pzoption != NULL) { + pharcontext = HASH_OF(pzoption); + if (idata->internal_file->uncompressed_filesize == 0 + && idata->internal_file->compressed_filesize == 0 + && (pzoption = zend_hash_str_find(pharcontext, "compress", sizeof("compress")-1)) != NULL + && Z_TYPE_P(pzoption) == IS_LONG + && (Z_LVAL_P(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0 + ) { + idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK; + idata->internal_file->flags |= Z_LVAL_P(pzoption); + } + if ((pzoption = zend_hash_str_find(pharcontext, "metadata", sizeof("metadata")-1)) != NULL) { + phar_metadata_tracker_free(&idata->internal_file->metadata_tracker, idata->internal_file->is_persistent); - metadata = pzoption; - ZVAL_COPY_DEREF(&idata->internal_file->metadata_tracker.val, metadata); - idata->phar->is_modified = 1; + metadata = pzoption; + ZVAL_COPY_DEREF(&idata->internal_file->metadata_tracker.val, metadata); + idata->phar->is_modified = 1; + } } } if (opened_path) { diff --git a/ext/zlib/zlib_filter.c b/ext/zlib/zlib_filter.c index 24d418ae04cfa..e43c1365584ac 100644 --- a/ext/zlib/zlib_filter.c +++ b/ext/zlib/zlib_filter.c @@ -321,9 +321,9 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f if (filterparams) { zval *tmpzval; + const HashTable *filter_params_ht = HASH_OF(filterparams); - if ((Z_TYPE_P(filterparams) == IS_ARRAY || Z_TYPE_P(filterparams) == IS_OBJECT) && - (tmpzval = zend_hash_str_find(HASH_OF(filterparams), "window", sizeof("window") - 1))) { + if (filter_params_ht != NULL && (tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("window")))) { /* log-2 base of history window (9 - 15) */ zend_long tmp = zval_get_long(tmpzval); if (tmp < -MAX_WBITS || tmp > MAX_WBITS + 32) { @@ -346,7 +346,6 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f if (filterparams) { - zval *tmpzval; zend_long tmp; /* filterparams can either be a scalar value to indicate compression level (shortcut method) @@ -354,34 +353,42 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f switch (Z_TYPE_P(filterparams)) { case IS_ARRAY: - case IS_OBJECT: - if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "memory", sizeof("memory") -1))) { + case IS_OBJECT: { + zval *tmpzval; + const HashTable *filter_params_ht = HASH_OF(filterparams); + ZEND_ASSERT(filter_params_ht != NULL); + + tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("memory")); + if (tmpzval != NULL) { /* Memory Level (1 - 9) */ tmp = zval_get_long(tmpzval); if (tmp < 1 || tmp > MAX_MEM_LEVEL) { php_error_docref(NULL, E_WARNING, "Invalid parameter given for memory level (" ZEND_LONG_FMT ")", tmp); } else { - memLevel = tmp; + memLevel = (int)tmp; } } - if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "window", sizeof("window") - 1))) { + tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("window")); + if (tmpzval != NULL) { /* log-2 base of history window (9 - 15) */ tmp = zval_get_long(tmpzval); if (tmp < -MAX_WBITS || tmp > MAX_WBITS + 16) { php_error_docref(NULL, E_WARNING, "Invalid parameter given for window size (" ZEND_LONG_FMT ")", tmp); } else { - windowBits = tmp; + windowBits = (int)tmp; } } - if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "level", sizeof("level") - 1))) { + tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("level")); + if (tmpzval != NULL) { tmp = zval_get_long(tmpzval); /* Pseudo pass through to catch level validating code */ goto factory_setlevel; } break; + } case IS_STRING: case IS_DOUBLE: case IS_LONG: