]> granicus.if.org Git - php/commitdiff
Make zend_hash_move_forward()/zenv_hash_move_backwards() a little smarter.
authorAndrei Zmievski <andrei@php.net>
Wed, 15 Mar 2000 16:25:59 +0000 (16:25 +0000)
committerAndrei Zmievski <andrei@php.net>
Wed, 15 Mar 2000 16:25:59 +0000 (16:25 +0000)
Zend/zend_hash.c
Zend/zend_hash.h

index ded362ec722d7172a4b18e7c168dcd3619ce39c2..a72778b6e1fb0a40f146035bc043f3efab8fe63c 100644 (file)
@@ -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;
 }
 
 
index bef0f074b1cbcf2f6ac9de68bbe1e779cc85bf5d..370b56001761edce757fa9d930427d7760651a51 100644 (file)
@@ -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);