line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "xh_config.h" |
2
|
|
|
|
|
|
|
#include "xh_core.h" |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
static int |
5
|
21
|
|
|
|
|
|
xh_sort_hash_cmp(const void *p1, const void *p2) |
6
|
|
|
|
|
|
|
{ |
7
|
21
|
|
|
|
|
|
return xh_strcmp(((xh_sort_hash_t *) p1)->key, ((xh_sort_hash_t *) p2)->key); |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
xh_sort_hash_t * |
11
|
8
|
|
|
|
|
|
xh_sort_hash(HV *hash, size_t len) |
12
|
|
|
|
|
|
|
{ |
13
|
|
|
|
|
|
|
xh_sort_hash_t *sorted_hash; |
14
|
|
|
|
|
|
|
size_t i; |
15
|
|
|
|
|
|
|
|
16
|
8
|
|
|
|
|
|
sorted_hash = malloc(sizeof(xh_sort_hash_t) * len); |
17
|
8
|
50
|
|
|
|
|
if (sorted_hash == NULL) { |
18
|
0
|
|
|
|
|
|
croak("Memory allocation error"); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
8
|
|
|
|
|
|
hv_iterinit(hash); |
22
|
|
|
|
|
|
|
|
23
|
30
|
100
|
|
|
|
|
for (i = 0; i < len; i++) { |
24
|
22
|
|
|
|
|
|
sorted_hash[i].value = hv_iternextsv(hash, (char **) &sorted_hash[i].key, &sorted_hash[i].key_len); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
8
|
|
|
|
|
|
qsort(sorted_hash, len, sizeof(xh_sort_hash_t), xh_sort_hash_cmp); |
28
|
|
|
|
|
|
|
|
29
|
8
|
|
|
|
|
|
return sorted_hash; |
30
|
|
|
|
|
|
|
} |