summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Zmievski <andrei@php.net>2000-03-15 16:25:59 +0000
committerAndrei Zmievski <andrei@php.net>2000-03-15 16:25:59 +0000
commitee286febe78a19c7e4f825f033380c454123c0cd (patch)
tree06c161ad927955f052faf1900f9b1a722f868a59
parentf30765e1a0c1a368c2402d89f4c1e0cb235b3a92 (diff)
downloadphp-git-ee286febe78a19c7e4f825f033380c454123c0cd.tar.gz
Make zend_hash_move_forward()/zenv_hash_move_backwards() a little smarter.
-rw-r--r--Zend/zend_hash.c28
-rw-r--r--Zend/zend_hash.h4
2 files changed, 18 insertions, 14 deletions
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index ded362ec72..a72778b6e1 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -918,26 +918,30 @@ ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos
}
-ZEND_API void zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos)
+ZEND_API int zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos)
{
+ HashPosition *current = pos ? pos : &ht->pInternalPointer;
+
IS_CONSISTENT(ht);
- if (pos) {
- *pos = (*pos)->pListNext;
- } else if (ht->pInternalPointer) {
- ht->pInternalPointer = ht->pInternalPointer->pListNext;
- }
+ if (*current) {
+ *current = (*current)->pListNext;
+ return SUCCESS;
+ } else
+ return FAILURE;
}
-ZEND_API void zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos)
+ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos)
{
+ HashPosition *current = pos ? pos : &ht->pInternalPointer;
+
IS_CONSISTENT(ht);
- if (pos) {
- *pos = (*pos)->pListLast;
- } else if (ht->pInternalPointer) {
- ht->pInternalPointer = ht->pInternalPointer->pListLast;
- }
+ if (*current) {
+ *current = (*current)->pListLast;
+ return SUCCESS;
+ } else
+ return FAILURE;
}
diff --git a/Zend/zend_hash.h b/Zend/zend_hash.h
index bef0f074b1..370b560017 100644
--- a/Zend/zend_hash.h
+++ b/Zend/zend_hash.h
@@ -148,8 +148,8 @@ ZEND_API int zend_hash_index_exists(HashTable *ht, ulong h);
ZEND_API ulong zend_hash_next_free_element(HashTable *ht);
/* traversing */
-ZEND_API void zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos);
-ZEND_API void zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos);
+ZEND_API int zend_hash_move_forward_ex(HashTable *ht, HashPosition *pos);
+ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos);
ZEND_API int zend_hash_get_current_key_ex(HashTable *ht, char **str_index, ulong *num_index, HashPosition *pos);
ZEND_API int zend_hash_get_current_key_type_ex(HashTable *ht, HashPosition *pos);
ZEND_API int zend_hash_get_current_data_ex(HashTable *ht, void **pData, HashPosition *pos);