Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Zend/zend_closures.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static zend_result do_closure_bind(zval *return_value, zval *zclosure, zend_obje

zend_closure *new_closure = (zend_closure*)Z_OBJ_P(return_value);
HashTable *static_variables = ZEND_MAP_PTR_GET(new_closure->func.op_array.static_variables_ptr);
ZEND_ASSERT(static_variables->nNumOfElements > 0);
ZEND_ASSERT(zend_hash_num_elements(static_variables) > 0);
zval *inner = &static_variables->arData[0].val;
ZEND_ASSERT(Z_TYPE_P(inner) == IS_OBJECT && Z_OBJCE_P(inner) == zend_ce_closure);

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ ZEND_API void zend_copy_ini_directives(void) /* {{{ */
EG(modified_ini_directives) = NULL;
EG(error_reporting_ini_entry) = NULL;
EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
zend_hash_init(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, true);
zend_hash_init(EG(ini_directives), zend_hash_num_elements(registered_zend_ini_directives), NULL, free_ini_entry, true);
zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, copy_ini_entry);
}
/* }}} */
Expand Down
4 changes: 2 additions & 2 deletions ext/opcache/zend_persist_calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,11 @@ uint32_t zend_accel_script_persist_calc(zend_persistent_script *new_persistent_s
new_persistent_script->size = (new_persistent_script->size + 63) & ~63;
#endif

if (new_persistent_script->script.class_table.nNumUsed != new_persistent_script->script.class_table.nNumOfElements) {
if (!HT_IS_WITHOUT_HOLES(&new_persistent_script->script.class_table)) {
zend_hash_rehash(&new_persistent_script->script.class_table);
}
zend_accel_persist_class_table_calc(&new_persistent_script->script.class_table);
if (new_persistent_script->script.function_table.nNumUsed != new_persistent_script->script.function_table.nNumOfElements) {
if (!HT_IS_WITHOUT_HOLES(&new_persistent_script->script.function_table)) {
zend_hash_rehash(&new_persistent_script->script.function_table);
}
zend_hash_persist_calc(&new_persistent_script->script.function_table);
Expand Down
2 changes: 1 addition & 1 deletion ext/phar/dirstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static php_stream *phar_make_dirstream(const char *dir, size_t dirlen, const Has
ALLOC_HASHTABLE(data);
zend_hash_init(data, 64, NULL, NULL, 0);

if ((*dir == '/' && dirlen == 1 && (manifest->nNumOfElements == 0)) || phar_path_is_magic_phar_ex(dir, dirlen)) {
if ((*dir == '/' && dirlen == 1 && (zend_hash_num_elements(manifest) == 0)) || phar_path_is_magic_phar_ex(dir, dirlen)) {
/* make empty root directory for empty phar */
/* make empty directory for .phar magic directory */
return php_stream_alloc(&phar_dir_ops, data, NULL, "r");
Expand Down
2 changes: 1 addition & 1 deletion ext/soap/php_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
zend_hash_move_forward(&ctx.services);
}

if (ctx.sdl->bindings == NULL || ctx.sdl->bindings->nNumOfElements == 0) {
if (ctx.sdl->bindings == NULL || zend_hash_num_elements(ctx.sdl->bindings) == 0) {
soap_error0(E_ERROR, "Parsing WSDL: Could not find any usable binding services in WSDL.");
}

Expand Down
28 changes: 14 additions & 14 deletions ext/standard/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -3199,7 +3199,7 @@ PHPAPI bool php_array_data_shuffle(php_random_algo_with_state engine, zval *arra
}

if (EXPECTED(!HT_HAS_ITERATORS(hash))) {
if (hash->nNumUsed != hash->nNumOfElements) {
if (!HT_IS_WITHOUT_HOLES(hash)) {
for (j = 0, idx = 0; idx < hash->nNumUsed; idx++) {
zv = hash->arPacked + idx;
if (Z_TYPE_P(zv) == IS_UNDEF) continue;
Expand Down Expand Up @@ -3227,7 +3227,7 @@ PHPAPI bool php_array_data_shuffle(php_random_algo_with_state engine, zval *arra
} else {
zend_long iter_pos = zend_hash_iterators_lower_pos(hash, 0);

if (hash->nNumUsed != hash->nNumOfElements) {
if (!HT_IS_WITHOUT_HOLES(hash)) {
for (j = 0, idx = 0; idx < hash->nNumUsed; idx++) {
zv = hash->arPacked + idx;
if (Z_TYPE_P(zv) == IS_UNDEF) continue;
Expand Down Expand Up @@ -3853,7 +3853,7 @@ static inline Bucket* find_bucket_at_offset(HashTable* ht, zend_long offset)
{
zend_long pos;
Bucket *bucket;
ZEND_ASSERT(offset >= 0 && offset <= ht->nNumOfElements);
ZEND_ASSERT(offset >= 0 && offset <= zend_hash_num_elements(ht));
if (HT_IS_WITHOUT_HOLES(ht)) {
/* There's no need to iterate over the array to filter out holes if there are no holes */
return ht->arData + offset;
Expand All @@ -3879,7 +3879,7 @@ static inline zval* find_packed_val_at_offset(HashTable* ht, zend_long offset)
{
zend_long pos;
zval *zv;
ZEND_ASSERT(offset >= 0 && offset <= ht->nNumOfElements);
ZEND_ASSERT(offset >= 0 && offset <= zend_hash_num_elements(ht));
if (HT_IS_WITHOUT_HOLES(ht)) {
/* There's no need to iterate over the array to filter out holes if there are no holes */
return ht->arPacked + offset;
Expand Down Expand Up @@ -5029,7 +5029,7 @@ PHP_FUNCTION(array_unique)
Z_PARAM_LONG(sort_type)
ZEND_PARSE_PARAMETERS_END();

if (Z_ARRVAL_P(array)->nNumOfElements <= 1) { /* nothing to do */
if (zend_hash_num_elements(Z_ARRVAL_P(array)) <= 1) { /* nothing to do */
ZVAL_COPY(return_value, array);
return;
}
Expand Down Expand Up @@ -5083,7 +5083,7 @@ PHP_FUNCTION(array_unique)
}

/* create and sort array with pointers to the target_hash buckets */
arTmp = pemalloc((Z_ARRVAL_P(array)->nNumOfElements + 1) * sizeof(struct bucketindex), GC_FLAGS(Z_ARRVAL_P(array)) & IS_ARRAY_PERSISTENT);
arTmp = pemalloc((zend_hash_num_elements(Z_ARRVAL_P(array)) + 1) * sizeof(struct bucketindex), GC_FLAGS(Z_ARRVAL_P(array)) & IS_ARRAY_PERSISTENT);
if (HT_IS_PACKED(Z_ARRVAL_P(array))) {
zval *zv = Z_ARRVAL_P(array)->arPacked;
for (i = 0, idx = 0; idx < Z_ARRVAL_P(array)->nNumUsed; idx++, zv++) {
Expand Down Expand Up @@ -5352,7 +5352,7 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
goto out;
}
hash = Z_ARRVAL(args[i]);
list = (Bucket *) pemalloc((hash->nNumOfElements + 1) * sizeof(Bucket), GC_FLAGS(hash) & IS_ARRAY_PERSISTENT);
list = (Bucket *) pemalloc((zend_hash_num_elements(hash) + 1) * sizeof(Bucket), GC_FLAGS(hash) & IS_ARRAY_PERSISTENT);
lists[i] = list;
ptrs[i] = list;
if (HT_IS_PACKED(hash)) {
Expand All @@ -5372,13 +5372,13 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int
}
}
ZVAL_UNDEF(&list->val);
if (hash->nNumOfElements > 1) {
if (zend_hash_num_elements(hash) > 1) {
if (behavior == INTERSECT_NORMAL) {
zend_sort((void *) lists[i], hash->nNumOfElements,
zend_sort((void *) lists[i], zend_hash_num_elements(hash),
sizeof(Bucket), (compare_func_t) intersect_data_compare_func,
(swap_func_t)zend_hash_bucket_swap);
} else if (behavior & INTERSECT_ASSOC) { /* triggered also when INTERSECT_KEY */
zend_sort((void *) lists[i], hash->nNumOfElements,
zend_sort((void *) lists[i], zend_hash_num_elements(hash),
sizeof(Bucket), (compare_func_t) intersect_key_compare_func,
(swap_func_t)zend_hash_bucket_swap);
}
Expand Down Expand Up @@ -5956,7 +5956,7 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
goto out;
}
hash = Z_ARRVAL(args[i]);
list = (Bucket *) pemalloc((hash->nNumOfElements + 1) * sizeof(Bucket), GC_FLAGS(hash) & IS_ARRAY_PERSISTENT);
list = (Bucket *) pemalloc((zend_hash_num_elements(hash) + 1) * sizeof(Bucket), GC_FLAGS(hash) & IS_ARRAY_PERSISTENT);
lists[i] = list;
ptrs[i] = list;
if (HT_IS_PACKED(hash)) {
Expand All @@ -5976,13 +5976,13 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_
}
}
ZVAL_UNDEF(&list->val);
if (hash->nNumOfElements > 1) {
if (zend_hash_num_elements(hash) > 1) {
if (behavior == DIFF_NORMAL) {
zend_sort((void *) lists[i], hash->nNumOfElements,
zend_sort((void *) lists[i], zend_hash_num_elements(hash),
sizeof(Bucket), (compare_func_t) diff_data_compare_func,
(swap_func_t)zend_hash_bucket_swap);
} else if (behavior & DIFF_ASSOC) { /* triggered also when DIFF_KEY */
zend_sort((void *) lists[i], hash->nNumOfElements,
zend_sort((void *) lists[i], zend_hash_num_elements(hash),
sizeof(Bucket), (compare_func_t) diff_key_compare_func,
(swap_func_t)zend_hash_bucket_swap);
}
Expand Down
Loading