]> granicus.if.org Git - php/commitdiff
Change zend_hash_get_current_key_ex() to also return the string length
authorZeev Suraski <zeev@php.net>
Tue, 2 May 2000 17:52:31 +0000 (17:52 +0000)
committerZeev Suraski <zeev@php.net>
Tue, 2 May 2000 17:52:31 +0000 (17:52 +0000)
Zend/zend_hash.c
Zend/zend_hash.h

index 073d511f6d5de3ba5ca671596bd2851c7b754020..7487eebf7ceae333463f5d9daedcfcead4cad8fe 100644 (file)
@@ -946,7 +946,7 @@ ZEND_API int zend_hash_move_backwards_ex(HashTable *ht, HashPosition *pos)
 
 
 /* This function should be made binary safe  */
-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_ex(HashTable *ht, char **str_index, ulong *str_length, ulong *num_index, HashPosition *pos)
 {
        Bucket *p;
    
@@ -958,6 +958,9 @@ ZEND_API int zend_hash_get_current_key_ex(HashTable *ht, char **str_index, ulong
                if (p->nKeyLength) {
                        *str_index = (char *) pemalloc(p->nKeyLength, ht->persistent);
                        memcpy(*str_index, p->arKey, p->nKeyLength);
+                       if (str_length) {
+                               *str_length = p->nKeyLength;
+                       }
                        return HASH_KEY_IS_STRING;
                } else {
                        *num_index = p->h;
index 2a5ef4035d22c3f72a38bae2c55c5f0ed285f33f..16641fa98c3f44e8288e5f61d434d7364ec45a49 100644 (file)
@@ -141,7 +141,7 @@ ZEND_API ulong zend_hash_next_free_element(HashTable *ht);
 /* traversing */
 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_ex(HashTable *ht, char **str_index, ulong *str_length, 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);
 ZEND_API void zend_hash_internal_pointer_reset_ex(HashTable *ht, HashPosition *pos);
@@ -152,7 +152,7 @@ ZEND_API void zend_hash_internal_pointer_end_ex(HashTable *ht, HashPosition *pos
 #define zend_hash_move_backwards(ht) \
        zend_hash_move_backwards_ex(ht, NULL)
 #define zend_hash_get_current_key(ht, str_index, num_index) \
-       zend_hash_get_current_key_ex(ht, str_index, num_index, NULL)
+       zend_hash_get_current_key_ex(ht, str_index, NULL, num_index, NULL)
 #define zend_hash_get_current_key_type(ht) \
        zend_hash_get_current_key_type_ex(ht, NULL)
 #define zend_hash_get_current_data(ht, pData) \