]> granicus.if.org Git - php/commitdiff
Modified zend_hash() to accept a pointer to sort function.
authorAndrei Zmievski <andrei@php.net>
Mon, 11 Oct 1999 21:30:23 +0000 (21:30 +0000)
committerAndrei Zmievski <andrei@php.net>
Mon, 11 Oct 1999 21:30:23 +0000 (21:30 +0000)
Zend/zend_hash.c
Zend/zend_hash.h

index 19e45a47efc5fa3b0337fd8a0361c58cd645ea97..54c5855b727a8d74ffb44d8050d76f8332a25122 100644 (file)
@@ -1098,7 +1098,9 @@ ZEND_API int zend_hash_get_current_data(HashTable *ht, void **pData)
 }
 
 
-ZEND_API int zend_hash_sort(HashTable *ht, int (*compar) (const void *, const void *), int renumber)
+ZEND_API int zend_hash_sort(HashTable *ht,
+                            void (*sort_func)(void *, size_t, size_t, compare_func_t),
+                            compare_func_t compar, int renumber)
 {
        Bucket **arTmp;
        Bucket *p;
@@ -1119,7 +1121,7 @@ ZEND_API int zend_hash_sort(HashTable *ht, int (*compar) (const void *, const vo
                i++;
        }
 
-       qsort((void *) arTmp, i, sizeof(Bucket *), compar);
+       (*sort_func)((void *) arTmp, i, sizeof(Bucket *), compar);
 
        HANDLE_BLOCK_INTERRUPTIONS();
        ht->pListHead = arTmp[0];
index be643772f0a901c8e0cb0c9ea8a9cb0ef86e5297..f5fc569f25c757fd1b318141c34d36473010fe71 100644 (file)
@@ -62,6 +62,7 @@ typedef struct hashtable {
        unsigned char persistent;
 } HashTable;
 
+typedef int (*compare_func_t) (const void *, const void *);
 
 BEGIN_EXTERN_C()
 
@@ -154,7 +155,7 @@ ZEND_API void zend_hash_internal_pointer_end(HashTable *ht);
 /* Copying, merging and sorting */
 ZEND_API void zend_hash_copy(HashTable *target, HashTable *source, void (*pCopyConstructor) (void *pData), void *tmp, uint size);
 ZEND_API void zend_hash_merge(HashTable *target, HashTable *source, void (*pCopyConstructor) (void *pData), void *tmp, uint size, int overwrite);
-ZEND_API int zend_hash_sort(HashTable *ht, int (*compar) (const void *, const void *), int renumber);
+ZEND_API int zend_hash_sort(HashTable *ht, void (*sort_func)(void *, size_t, size_t, compare_func_t), compare_func_t compar, int renumber);
 ZEND_API int zend_hash_minmax(HashTable *ht, int (*compar) (const void *, const void *), int flag, void **pData);
 
 ZEND_API int zend_hash_num_elements(HashTable *ht);