diff options
Diffstat (limited to 'cddl/contrib/opensolaris/tools/ctf/cvt/alist.c')
-rw-r--r-- | cddl/contrib/opensolaris/tools/ctf/cvt/alist.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c b/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c index 8e776dc08a7f..415a6cd3335b 100644 --- a/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c +++ b/cddl/contrib/opensolaris/tools/ctf/cvt/alist.c @@ -52,19 +52,16 @@ typedef struct alist_el { } alist_el_t; static int -alist_hash(int nbuckets, void *arg) +alist_hash(int nbuckets, alist_el_t *el) { - alist_el_t *el = arg; uintptr_t num = (uintptr_t)el->ale_name; return (num % nbuckets); } static int -alist_cmp(void *arg1, void *arg2) +alist_cmp(alist_el_t *el1, alist_el_t *el2) { - alist_el_t *el1 = arg1; - alist_el_t *el2 = arg2; return ((uintptr_t)el1->ale_name != (uintptr_t)el2->ale_name); } @@ -87,14 +84,12 @@ alist_t * alist_new(void (*namefree)(void *), void (*valfree)(void *)) { return (alist_xnew(ALIST_HASH_SIZE, namefree, valfree, - alist_hash, alist_cmp)); + (int (*)())alist_hash, (int (*)())alist_cmp)); } static void -alist_free_cb(void *arg1, void *arg2) +alist_free_cb(alist_el_t *el, alist_t *alist) { - alist_el_t *el = arg1; - alist_t *alist = arg2; if (alist->al_namefree) alist->al_namefree(el->ale_name); if (alist->al_valfree) @@ -105,7 +100,7 @@ alist_free_cb(void *arg1, void *arg2) void alist_free(alist_t *alist) { - hash_free(alist->al_elements, alist_free_cb, alist); + hash_free(alist->al_elements, (void (*)())alist_free_cb, alist); free(alist); } @@ -123,17 +118,14 @@ alist_add(alist_t *alist, void *name, void *value) int alist_find(alist_t *alist, void *name, void **value) { - alist_el_t template, *retx; - void *ret; + alist_el_t template, *ret; template.ale_name = name; - if (!hash_find(alist->al_elements, &template, &ret)) + if (!hash_find(alist->al_elements, &template, (void **)&ret)) return (0); - if (value) { - retx = ret; - *value = retx->ale_value; - } + if (value) + *value = ret->ale_value; return (1); } @@ -144,10 +136,8 @@ typedef struct alist_iter_data { } alist_iter_data_t; static int -alist_iter_cb(void *arg1, void *arg2) +alist_iter_cb(alist_el_t *el, alist_iter_data_t *aid) { - alist_el_t *el = arg1; - alist_iter_data_t *aid = arg2; return (aid->aid_func(el->ale_name, el->ale_value, aid->aid_priv)); } @@ -159,7 +149,7 @@ alist_iter(alist_t *alist, int (*func)(void *, void *, void *), void *private) aid.aid_func = func; aid.aid_priv = private; - return (hash_iter(alist->al_elements, alist_iter_cb, &aid)); + return (hash_iter(alist->al_elements, (int (*)())alist_iter_cb, &aid)); } /* @@ -181,13 +171,13 @@ alist_def_print_cb(void *key, void *value) { printf("Key: "); if (alist_def_print_cb_key_int == 1) - printf("%5lu ", (ulong_t)key); + printf("%5d ", (int)key); else printf("%s\n", (char *)key); printf("Value: "); if (alist_def_print_cb_value_int == 1) - printf("%5lu\n", (ulong_t)value); + printf("%5d\n", (int)value); else printf("%s\n", (char *)key); @@ -197,7 +187,7 @@ alist_def_print_cb(void *key, void *value) static int alist_dump_cb(void *node, void *private) { - int (*printer)(void *, void *) = private; + int (*printer)(void *, void *) = (int (*)())private; alist_el_t *el = node; printer(el->ale_name, el->ale_value); |