&(ht)->nInternalPointer should be passed instead of NULL.
zend_hash_update_current_key() may work only with internal pointer.
if (Z_REFCOUNTED_P(entry)) Z_ADDREF_P(entry);
/* add the key elements */
- switch (zend_hash_get_current_key_ex(target_hash, &key, &num_key, 0, NULL)) {
+ switch (zend_hash_get_current_key(target_hash, &key, &num_key, 0)) {
case HASH_KEY_IS_STRING:
inserted_pointer = add_get_index_str(return_value, 0, STR_COPY(key));
break;
array_init(return_value);
zend_hash_internal_pointer_reset(&EG(included_files));
- while (zend_hash_get_current_key_ex(&EG(included_files), &entry, NULL, 0, NULL) == HASH_KEY_IS_STRING) {
+ while (zend_hash_get_current_key(&EG(included_files), &entry, NULL, 0) == HASH_KEY_IS_STRING) {
add_next_index_str(return_value, STR_COPY(entry));
zend_hash_move_forward(&EG(included_files));
}
/* First go over the array and see if there are any constant indices */
zend_hash_internal_pointer_reset(Z_ARRVAL_P(p));
while ((element = zend_hash_get_current_data(Z_ARRVAL_P(p))) != NULL) {
- if (zend_hash_get_current_key_ex(Z_ARRVAL_P(p), &str_index, &num_index, 0, NULL) != HASH_KEY_IS_STRING) {
+ if (zend_hash_get_current_key(Z_ARRVAL_P(p), &str_index, &num_index, 0) != HASH_KEY_IS_STRING) {
zend_hash_move_forward(Z_ARRVAL_P(p));
continue;
}
switch (Z_TYPE(const_value)) {
case IS_STRING:
- ret = zend_symtable_update_current_key(Z_ARRVAL_P(p), Z_STR(const_value), HASH_UPDATE_KEY_IF_BEFORE);
+ ret = zend_symtable_update_current_key_ex(Z_ARRVAL_P(p), Z_STR(const_value), HASH_UPDATE_KEY_IF_BEFORE);
break;
case IS_BOOL:
case IS_LONG:
- ret = zend_hash_update_current_key_ex(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL, Z_LVAL(const_value), HASH_UPDATE_KEY_IF_BEFORE, NULL);
+ ret = zend_hash_update_current_key_ex(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL, Z_LVAL(const_value), HASH_UPDATE_KEY_IF_BEFORE);
break;
case IS_DOUBLE:
- ret = zend_hash_update_current_key_ex(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL, zend_dval_to_lval(Z_DVAL(const_value)), HASH_UPDATE_KEY_IF_BEFORE, NULL);
+ ret = zend_hash_update_current_key_ex(Z_ARRVAL_P(p), HASH_KEY_IS_LONG, NULL, zend_dval_to_lval(Z_DVAL(const_value)), HASH_UPDATE_KEY_IF_BEFORE);
break;
case IS_NULL:
- ret = zend_hash_update_current_key_ex(Z_ARRVAL_P(p), HASH_KEY_IS_STRING, STR_EMPTY_ALLOC(), 0, HASH_UPDATE_KEY_IF_BEFORE, NULL);
+ ret = zend_hash_update_current_key_ex(Z_ARRVAL_P(p), HASH_KEY_IS_STRING, STR_EMPTY_ALLOC(), 0, HASH_UPDATE_KEY_IF_BEFORE);
break;
default:
ret = SUCCESS;
uint idx;
IS_CONSISTENT(ht);
-
for (idx = 0; idx < ht->nNumUsed; idx++) {
if (Z_TYPE(ht->arData[idx].val) != IS_UNDEF) {
- if (pos) {
- *pos = idx;
- } else {
- ht->nInternalPointer = idx;
- }
+ *pos = idx;
return;
}
}
- if (pos) {
- *pos = INVALID_IDX;
- } else {
- ht->nInternalPointer = INVALID_IDX;
- }
+ *pos = INVALID_IDX;
}
while (idx > 0) {
idx--;
if (Z_TYPE(ht->arData[idx].val) != IS_UNDEF) {
- if (pos) {
- *pos = idx;
- } else {
- ht->nInternalPointer = idx;
- }
+ *pos = idx;
return;
}
}
- if (pos) {
- *pos = INVALID_IDX;
- } else {
- ht->nInternalPointer = INVALID_IDX;
- }
+ *pos = INVALID_IDX;
}
ZEND_API int zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos)
{
- HashPosition *current = pos ? pos : &ht->nInternalPointer;
- uint idx = *current;
+ uint idx = *pos;
IS_CONSISTENT(ht);
while (1) {
idx++;
if (idx >= ht->nNumUsed) {
- *current = INVALID_IDX;
+ *pos = INVALID_IDX;
return SUCCESS;
}
if (Z_TYPE(ht->arData[idx].val) != IS_UNDEF) {
- *current = idx;
+ *pos = idx;
return SUCCESS;
}
}
ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos)
{
- HashPosition *current = pos ? pos : &ht->nInternalPointer;
- uint idx = *current;
+ uint idx = *pos;
IS_CONSISTENT(ht);
while (idx > 0) {
idx--;
if (Z_TYPE(ht->arData[idx].val) != IS_UNDEF) {
- *current = idx;
+ *pos = idx;
return SUCCESS;
}
}
- *current = INVALID_IDX;
+ *pos = INVALID_IDX;
return SUCCESS;
} else {
return FAILURE;
/* This function should be made binary safe */
ZEND_API int zend_hash_get_current_key_ex(const HashTable *ht, zend_string **str_index, ulong *num_index, zend_bool duplicate, HashPosition *pos)
{
- uint idx;
+ uint idx = *pos;
Bucket *p;
- idx = pos ? (*pos) : ht->nInternalPointer;
-
IS_CONSISTENT(ht);
-
if (idx != INVALID_IDX) {
p = ht->arData + idx;
if (p->key) {
ZEND_API void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key, HashPosition *pos)
{
- uint idx;
+ uint idx = *pos;
Bucket *p;
IS_CONSISTENT(ht);
-
- idx = pos ? (*pos) : ht->nInternalPointer;
-
if (idx == INVALID_IDX) {
ZVAL_NULL(key);
} else {
ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos)
{
- uint idx;
+ uint idx = *pos;
Bucket *p;
- idx = pos ? (*pos) : ht->nInternalPointer;
-
IS_CONSISTENT(ht);
-
if (idx != INVALID_IDX) {
p = ht->arData + idx;
if (p->key) {
ZEND_API zval *zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos)
{
- uint idx;
+ uint idx = *pos;
Bucket *p;
- idx = pos ? (*pos) : ht->nInternalPointer;
-
IS_CONSISTENT(ht);
-
if (idx != INVALID_IDX) {
p = ht->arData + idx;
return &p->val;
/* This function changes key of current element without changing elements'
* order. If element with target key already exists, it will be deleted first.
*/
-ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, zend_string *str_index, ulong num_index, int mode, HashPosition *pos)
+ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, zend_string *str_index, ulong num_index, int mode)
{
- uint idx1, idx2;
+ uint idx1 = ht->nInternalPointer;
+ uint idx2;
Bucket *p, *q;
ulong h;
#ifdef ZEND_SIGNALS
TSRMLS_FETCH();
#endif
- idx1 = pos ? (*pos) : ht->nInternalPointer;
-
IS_CONSISTENT(ht);
-
if (idx1 != INVALID_IDX) {
p = ht->arData + idx1;
if (key_type == HASH_KEY_IS_LONG) {
ZEND_API zval *zend_hash_get_current_data_ex(HashTable *ht, HashPosition *pos);
ZEND_API void zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos);
ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos);
-ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, zend_string *str_index, ulong num_index, int mode, HashPosition *pos);
+ZEND_API int zend_hash_update_current_key_ex(HashTable *ht, int key_type, zend_string *str_index, ulong num_index, int mode);
typedef struct _HashPointer {
HashPosition pos;
ZEND_API int zend_hash_set_pointer(HashTable *ht, const HashPointer *ptr);
#define zend_hash_has_more_elements(ht) \
- zend_hash_has_more_elements_ex(ht, NULL)
+ zend_hash_has_more_elements_ex(ht, &(ht)->nInternalPointer)
#define zend_hash_move_forward(ht) \
- zend_hash_move_forward_ex(ht, NULL)
+ zend_hash_move_forward_ex(ht, &(ht)->nInternalPointer)
#define zend_hash_move_backwards(ht) \
- zend_hash_move_backwards_ex(ht, NULL)
+ zend_hash_move_backwards_ex(ht, &(ht)->nInternalPointer)
#define zend_hash_get_current_key(ht, str_index, num_index, duplicate) \
- zend_hash_get_current_key_ex(ht, str_index, num_index, duplicate, NULL)
+ zend_hash_get_current_key_ex(ht, str_index, num_index, duplicate, &(ht)->nInternalPointer)
#define zend_hash_get_current_key_zval(ht, key) \
- zend_hash_get_current_key_zval_ex(ht, key, NULL)
+ zend_hash_get_current_key_zval_ex(ht, key, &(ht)->nInternalPointer)
#define zend_hash_get_current_key_type(ht) \
- zend_hash_get_current_key_type_ex(ht, NULL)
+ zend_hash_get_current_key_type_ex(ht, &(ht)->nInternalPointer)
#define zend_hash_get_current_data(ht) \
- zend_hash_get_current_data_ex(ht, NULL)
+ zend_hash_get_current_data_ex(ht, &(ht)->nInternalPointer)
#define zend_hash_internal_pointer_reset(ht) \
- zend_hash_internal_pointer_reset_ex(ht, NULL)
+ zend_hash_internal_pointer_reset_ex(ht, &(ht)->nInternalPointer)
#define zend_hash_internal_pointer_end(ht) \
- zend_hash_internal_pointer_end_ex(ht, NULL)
+ zend_hash_internal_pointer_end_ex(ht, &(ht)->nInternalPointer)
#define zend_hash_update_current_key(ht, key_type, str_index, str_length, num_index) \
- zend_hash_update_current_key_ex(ht, key_type, str_index, str_length, num_index, HASH_UPDATE_KEY_ANYWAY, NULL)
+ zend_hash_update_current_key_ex(ht, key_type, str_index, str_length, num_index, HASH_UPDATE_KEY_ANYWAY)
/* Copying, merging and sorting */
ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, copy_ctor_func_t pCopyConstructor);
return zend_hash_str_exists(ht, str, len);
}
-static inline int zend_symtable_update_current_key_ex(HashTable *ht, zend_string *key, int mode, HashPosition *pos)
+static inline int zend_symtable_update_current_key_ex(HashTable *ht, zend_string *key, int mode)
{
-ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_update_current_key_ex(ht, HASH_KEY_IS_LONG, NULL, idx, mode, pos));
- return zend_hash_update_current_key_ex(ht, HASH_KEY_IS_STRING, key, 0, mode, pos);
+ZEND_HANDLE_NUMERIC(key->val, key->len+1, zend_hash_update_current_key_ex(ht, HASH_KEY_IS_LONG, NULL, idx, mode));
+ return zend_hash_update_current_key_ex(ht, HASH_KEY_IS_STRING, key, 0, mode);
}
-#define zend_symtable_update_current_key(ht, key, mode) \
- zend_symtable_update_current_key_ex(ht, key, mode, NULL)
static inline void *zend_hash_add_ptr(HashTable *ht, zend_string *key, void *pData)
{
}
#define zend_hash_get_current_data_ptr(ht) \
- zend_hash_get_current_data_ptr_ex(ht, NULL)
+ zend_hash_get_current_data_ptr_ex(ht, &(ht)->nInternalPointer)
#endif /* ZEND_HASH_H */
ulong int_key;
zend_uchar key_type;
- key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &int_key, 0, NULL);
+ key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
if (key_type != HASH_KEY_NON_EXISTENT &&
(key_type == HASH_KEY_IS_LONG ||
zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS)) {
}
}
- key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &int_key, 0, NULL);
+ key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
zend_hash_move_forward(fe_ht);
if (key_type == HASH_KEY_IS_LONG ||
ulong int_key;
zend_uchar key_type;
- key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &int_key, 0, NULL);
+ key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
if (key_type != HASH_KEY_NON_EXISTENT &&
(key_type == HASH_KEY_IS_LONG ||
zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS)) {
ulong int_key;
zend_uchar key_type;
- key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &int_key, 0, NULL);
+ key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
if (key_type != HASH_KEY_NON_EXISTENT &&
(key_type == HASH_KEY_IS_LONG ||
zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS)) {
ulong int_key;
zend_uchar key_type;
- key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &int_key, 0, NULL);
+ key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
if (key_type != HASH_KEY_NON_EXISTENT &&
(key_type == HASH_KEY_IS_LONG ||
zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS)) {
}
}
- key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &int_key, 0, NULL);
+ key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
zend_hash_move_forward(fe_ht);
if (key_type == HASH_KEY_IS_LONG ||
ulong int_key;
zend_uchar key_type;
- key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &int_key, 0, NULL);
+ key_type = zend_hash_get_current_key(fe_ht, &str_key, &int_key, 0);
if (key_type != HASH_KEY_NON_EXISTENT &&
(key_type == HASH_KEY_IS_LONG ||
zend_check_property_access(zobj, str_key TSRMLS_CC) == SUCCESS)) {
if ((result = php_replace_in_subject(regex, replace, subject_entry, limit_val, is_callable_replace, &replace_count TSRMLS_CC)) != NULL) {
if (!is_filter || replace_count > old_replace_count) {
/* Add to return array */
- switch(zend_hash_get_current_key_ex(Z_ARRVAL_P(subject), &string_key, &num_key, 0, NULL))
+ switch(zend_hash_get_current_key(Z_ARRVAL_P(subject), &string_key, &num_key, 0))
{
case HASH_KEY_IS_STRING:
add_assoc_str_ex(return_value, string_key->val, string_key->len, result);
}
/* Add to return array */
- switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(input), &string_key, &num_key, 0, NULL))
+ switch (zend_hash_get_current_key(Z_ARRVAL_P(input), &string_key, &num_key, 0))
{
case HASH_KEY_IS_STRING:
zend_hash_update(Z_ARRVAL_P(return_value), string_key, entry);
int key_type; \
\
for (zend_hash_internal_pointer_reset(_ht); \
- (key_type = zend_hash_get_current_key_ex(_ht, &key, \
- &num_key, 0, NULL)) != HASH_KEY_NON_EXISTENT; \
+ (key_type = zend_hash_get_current_key(_ht, &key, \
+ &num_key, 0)) != HASH_KEY_NON_EXISTENT; \
zend_hash_move_forward(_ht)) { \
if (key_type == HASH_KEY_IS_LONG) { \
php_error_docref(NULL TSRMLS_CC, E_NOTICE, \
RETVAL_ZVAL_FAST(val);
/* Delete the first or last value */
- zend_hash_get_current_key_ex(Z_ARRVAL_P(stack), &key, &index, 0, NULL);
+ zend_hash_get_current_key(Z_ARRVAL_P(stack), &key, &index, 0);
if (key && Z_ARRVAL_P(stack) == &EG(symbol_table).ht) {
zend_delete_global_variable(key TSRMLS_CC);
} else if (key) {
arg_sep_len = strlen(arg_sep);
for (zend_hash_internal_pointer_reset(ht);
- (key_type = zend_hash_get_current_key_ex(ht, &key, &idx, 0, NULL)) != HASH_KEY_NON_EXISTENT;
+ (key_type = zend_hash_get_current_key(ht, &key, &idx, 0)) != HASH_KEY_NON_EXISTENT;
zend_hash_move_forward(ht)
) {
/* handling for private & protected object properties */
prop_len = 0;
}
- if ((zdata = zend_hash_get_current_data_ex(ht, NULL)) == NULL) {
+ if ((zdata = zend_hash_get_current_data(ht)) == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Error traversing form data array");
return FAILURE;
}
php_info_print(name);
php_info_print("[\"");
- switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(data), &string_key, &num_key, 0, NULL)) {
+ switch (zend_hash_get_current_key(Z_ARRVAL_P(data), &string_key, &num_key, 0)) {
case HASH_KEY_IS_STRING:
if (!sapi_module.phpinfo_as_text) {
php_info_print_html_esc(string_key->val, string_key->len);
int tmp_fd;
- type = zend_hash_get_current_key_ex(Z_ARRVAL_P(stream_array),
- &key, &num_ind, 0, NULL);
+ type = zend_hash_get_current_key(Z_ARRVAL_P(stream_array),
+ &key, &num_ind, 0);
if (type == HASH_KEY_NON_EXISTENT ||
(elem = zend_hash_get_current_data(Z_ARRVAL_P(stream_array))) == NULL) {
continue; /* should not happen */
COPY_PZVAL_TO_ZVAL(result, subject_entry);
}
/* Add to return array */
- switch (zend_hash_get_current_key_ex(Z_ARRVAL_P(subject), &string_key,
- &num_key, 0, NULL)) {
+ switch (zend_hash_get_current_key(Z_ARRVAL_P(subject), &string_key,
+ &num_key, 0)) {
case HASH_KEY_IS_STRING:
zend_hash_update(Z_ARRVAL_P(return_value), string_key, &result);
break;
if (filters_hash) {
for(zend_hash_internal_pointer_reset(filters_hash);
- (key_flags = zend_hash_get_current_key_ex(filters_hash, &filter_name, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTENT;
+ (key_flags = zend_hash_get_current_key(filters_hash, &filter_name, &num_key, 0)) != HASH_KEY_NON_EXISTENT;
zend_hash_move_forward(filters_hash))
if (key_flags == HASH_KEY_IS_STRING) {
add_next_index_str(return_value, STR_COPY(filter_name));
/* Walk through config hash and alter matching ini entries using the values found in the hash */
for (zend_hash_internal_pointer_reset(source_hash);
- zend_hash_get_current_key_ex(source_hash, &str, &num_index, 0, NULL) == HASH_KEY_IS_STRING;
+ zend_hash_get_current_key(source_hash, &str, &num_index, 0) == HASH_KEY_IS_STRING;
zend_hash_move_forward(source_hash)
) {
data = zend_hash_get_current_data(source_hash);