From 30d1744ffce823312d51379585e8c19f722ea4d6 Mon Sep 17 00:00:00 2001 From: Sean Bright Date: Fri, 7 Nov 2008 22:39:30 +0000 Subject: Add ability to pass arbitrary data to the ao2_callback_fn (called from ao2_callback and ao2_find). Currently, passing OBJ_POINTER to either of these mandates that the passed 'arg' is a hashable object, making searching for an ao2 object based on outside criteria difficult. Reviewed by Russell and Mark M. via ReviewBoard: http://reviewboard.digium.com/r/36/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@155401 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- utils/hashtest2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'utils/hashtest2.c') diff --git a/utils/hashtest2.c b/utils/hashtest2.c index 3b0c62699..41582998c 100644 --- a/utils/hashtest2.c +++ b/utils/hashtest2.c @@ -80,7 +80,7 @@ static int hash_string(const void *obj, const int flags) return total; } -static int hashtab_compare_strings(void *a, void *b, int flags) +static int hashtab_compare_strings(void *a, void *b, void *data, int flags) { const struct ht_element *ae = a, *be = b; return !strcmp(ae->key, be->key) ? CMP_MATCH | CMP_STOP : 0; @@ -137,7 +137,7 @@ static void add_element(void) els_added++; /* unprotected, sometimes off, but, not really important, either */ } -static int do_nothing_cb(void *obj, void *arg, int flags) +static int do_nothing_cb(void *obj, void *arg, void *data, int flags) { return 0; } @@ -147,7 +147,7 @@ static void traverse_elements(void) #ifdef DEBUG printf("Traverse hashtab\n"); #endif - ao2_callback(glob_hashtab, OBJ_NODATA, do_nothing_cb, NULL); + ao2_callback(glob_hashtab, OBJ_NODATA, do_nothing_cb, NULL, NULL); els_traversals++; /* unprotected, sometimes off, but, not really important, either */ } @@ -164,7 +164,7 @@ static void * del_element(unsigned int *seedp) printf("- %s", keybuf); #endif lookup.key = keybuf; - el = ao2_find(glob_hashtab, &lookup, OBJ_POINTER); + el = ao2_find(glob_hashtab, &lookup, NULL, OBJ_POINTER); if (el) { #ifdef DEBUG printf("...YES (el=%x)\n", (unsigned long)el); @@ -190,7 +190,7 @@ static int lookup_element(unsigned int *seedp) x = my_rand(0,glob_highwater-1,seedp); sprintf(keybuf, "key%08d", x); lookup.key = keybuf; - el = ao2_find(glob_hashtab, &lookup, OBJ_POINTER); + el = ao2_find(glob_hashtab, &lookup, NULL, OBJ_POINTER); els_lookedup++; if (el) { els_found++; -- cgit v1.2.3