mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Modified zend_hash() to accept a pointer to sort function.
This commit is contained in:
parent
4d52ee2bc6
commit
8864313c48
@ -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];
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user