[svn-commits] murf: branch murf/fast-ast2 r88452 - in /team/murf/fast-ast2: include/asteris...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sat Nov 3 17:24:31 CDT 2007


Author: murf
Date: Sat Nov  3 17:24:31 2007
New Revision: 88452

URL: http://svn.digium.com/view/asterisk?view=rev&rev=88452
Log:
some hashtable hash func return type cleanup

Modified:
    team/murf/fast-ast2/include/asterisk/hashtab.h
    team/murf/fast-ast2/main/hashtab.c
    team/murf/fast-ast2/main/pbx.c

Modified: team/murf/fast-ast2/include/asterisk/hashtab.h
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast2/include/asterisk/hashtab.h?view=diff&rev=88452&r1=88451&r2=88452
==============================================================================
--- team/murf/fast-ast2/include/asterisk/hashtab.h (original)
+++ team/murf/fast-ast2/include/asterisk/hashtab.h Sat Nov  3 17:24:31 2007
@@ -83,7 +83,7 @@
 													 rets -1 if a < b; rets 0 if a==b; rets 1 if a>b */
 	int (*newsize) (struct ast_hashtab *tab);     /* a ptr to func that returns int, a new size for hash tab, based on curr_size */
 	int (*resize) (struct ast_hashtab *tab);      /* a function to decide whether this hashtable should be resized now */
-	int (*hash) (const void *obj);         /* a hash func ptr for this table. Given a raw ptr to an obj, 
+	unsigned int (*hash) (const void *obj);         /* a hash func ptr for this table. Given a raw ptr to an obj, 
 													 it calcs a hash.*/
 	int hash_tab_size;                            /* the size of the bucket array */
 	int hash_tab_elements;                        /* the number of objects currently stored in the table */
@@ -136,19 +136,19 @@
 int ast_hashtab_newsize_none(struct ast_hashtab *tab); /* always return current size -- no resizing */
 
 
-int ast_hashtab_hash_string(const void *obj); /* hashes a string to a number, mod is applied so it in the range 0 to mod-1 */
-
-
-int ast_hashtab_hash_string_nocase(const void *obj);  /* upcases each char before using them for a hash */
-
-
-int ast_hashtab_hash_string_sax(const void *obj); /* from Josh */
-
-
-int ast_hashtab_hash_int(const int num);  /* right now, both these funcs are just result = num%modulus; */
-
-
-int ast_hashtab_hash_short(const short num);
+unsigned int ast_hashtab_hash_string(const void *obj); /* hashes a string to a number, mod is applied so it in the range 0 to mod-1 */
+
+
+unsigned int ast_hashtab_hash_string_nocase(const void *obj);  /* upcases each char before using them for a hash */
+
+
+unsigned int ast_hashtab_hash_string_sax(const void *obj); /* from Josh */
+
+
+unsigned int ast_hashtab_hash_int(const int num);  /* right now, both these funcs are just result = num%modulus; */
+
+
+unsigned int ast_hashtab_hash_short(const short num);
 
 
 struct ast_hashtab * ast_hashtab_create(int initial_buckets,
@@ -157,7 +157,7 @@
 										a NULL ptr here will cause a default to be used */
 					int (*newsize)(struct ast_hashtab *tab), /* a ptr to func that returns a new size of the array. 
 										A NULL will cause a default to be used */
-					int (*hash)(const void *obj),     /* a func to do the hashing */
+					unsigned int (*hash)(const void *obj),     /* a func to do the hashing */
 					int do_locking );                        /* use locks to guarantee safety of iterators/insertion/deletion */
 
 

Modified: team/murf/fast-ast2/main/hashtab.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast2/main/hashtab.c?view=diff&rev=88452&r1=88451&r2=88452
==============================================================================
--- team/murf/fast-ast2/main/hashtab.c (original)
+++ team/murf/fast-ast2/main/hashtab.c Sat Nov  3 17:24:31 2007
@@ -153,7 +153,7 @@
 	return tab->hash_tab_size;
 }
 
-int ast_hashtab_hash_string(const void *obj)
+unsigned int ast_hashtab_hash_string(const void *obj)
 {
 	unsigned char *str = (unsigned char*)obj;
 	unsigned int total;
@@ -171,7 +171,7 @@
 	return total;
 }
 
-int ast_hashtab_hash_string_sax(const void *obj) /* from Josh */
+unsigned int ast_hashtab_hash_string_sax(const void *obj) /* from Josh */
 {
 	unsigned char *str = (unsigned char*)obj;
 	unsigned int total = 0, c = 0;
@@ -182,7 +182,7 @@
 	return total;
 }
 
-int ast_hashtab_hash_string_nocase(const void *obj)
+unsigned int ast_hashtab_hash_string_nocase(const void *obj)
 {
 	unsigned char *str = (unsigned char*)obj;
 	unsigned int total;
@@ -206,12 +206,12 @@
 	return total;
 }
 
-int ast_hashtab_hash_int(const int x)
+unsigned int ast_hashtab_hash_int(const int x)
 {
 	return x;
 }
 
-int ast_hashtab_hash_short(const short x)
+unsigned int ast_hashtab_hash_short(const short x)
 {
 	/* hmmmm.... modulus is best < 65535 !! */
 	return x;
@@ -221,7 +221,7 @@
 										int (*compare)(const void *a, const void *b), /* a func to compare two elements in the hash -- cannot be null  */
 										int (*resize)(struct ast_hashtab *), /* a func to decide if the table needs to be resized, a NULL ptr here will cause a default to be used */
 										int (*newsize)(struct ast_hashtab *tab), /* a ptr to func that returns a new size of the array. A NULL will cause a default to be used */
-										int (*hash)(const void *obj), /* a func to do the hashing */
+										unsigned int (*hash)(const void *obj), /* a func to do the hashing */
 										int do_locking ) /* use locks to guarantee safety of iterators/insertion/deletion -- real simpleminded right now */
 {
 	struct ast_hashtab *ht = ast_calloc(1,sizeof(struct ast_hashtab));
@@ -393,7 +393,7 @@
 	}
 	if (tab->do_locking)
 		ast_rwlock_wrlock(&tab->lock);
-	h = ((unsigned int)((*tab->hash)(obj))) % tab->hash_tab_size;
+	h = (*tab->hash)(obj) % tab->hash_tab_size;
 	for (c=0,b=tab->array[h];b;b=b->next) {
 		c++;
 	}
@@ -484,7 +484,7 @@
 	
 	if (tab->do_locking)
 		ast_rwlock_rdlock(&tab->lock);
-	h = ((unsigned int)((*tab->hash)(obj))) % tab->hash_tab_size;
+	h = (*tab->hash)(obj) % tab->hash_tab_size;
 	for (b=tab->array[h]; b; b=b->next) {
 		if ((*tab->compare)(obj,b->object) == 0) {
 			ret = b->object;
@@ -533,7 +533,7 @@
 	if (!tab || !obj)
 		return 0;
 	
-	h = ((unsigned int)((*tab->hash)(obj))) % tab->hash_tab_size;
+	h = (*tab->hash)(obj) % tab->hash_tab_size;
 	for (b=tab->array[h]; b; b=b->next) {
 		if ((*tab->compare)(obj,b->object) == 0) {
 			return (void*)b->object; /* I can't touch obj in this func, but the outside world is welcome to */
@@ -602,7 +602,7 @@
 	{
 		b->prev = 0;
 		bn = b->tnext;
-		h = ((unsigned int)((*tab->hash)(b->object))) % tab->hash_tab_size;
+		h = (*tab->hash)(b->object) % tab->hash_tab_size;
 		b->next = tab->array[h];
 		if (b->next)
 			b->next->prev = b;
@@ -723,7 +723,7 @@
 		return 0;
 	if (tab->do_locking)
 		ast_rwlock_wrlock(&tab->lock);
-	h = ((unsigned int)((*tab->hash)(obj))) % tab->hash_tab_size;
+	h = (*tab->hash)(obj) % tab->hash_tab_size;
 	for (b=tab->array[h]; b; b=b->next)
 	{
 		void *obj2;
@@ -751,7 +751,7 @@
 
 	if (!tab || !obj)
 		return 0;
-	h = ((unsigned int)((*tab->hash)(obj))) % tab->hash_tab_size;
+	h = (*tab->hash)(obj) % tab->hash_tab_size;
 	for (b=tab->array[h]; b; b=b->next)
 	{
 		void *obj2;
@@ -783,7 +783,7 @@
 	if (tab->do_locking)
 		ast_rwlock_wrlock(&tab->lock);
 
-	h = ((unsigned int)((*tab->hash)(obj))) % tab->hash_tab_size;
+	h = (*tab->hash)(obj) % tab->hash_tab_size;
 	for (b=tab->array[h]; b; b=b->next)
 	{
 		const void *obj2;
@@ -815,7 +815,7 @@
 	if (!tab || !obj)
 		return 0;
  
-	h = ((unsigned int)((*tab->hash)(obj))) % tab->hash_tab_size;
+	h = (*tab->hash)(obj) % tab->hash_tab_size;
 	for (b=tab->array[h]; b; b=b->next)
 	{
 		const void *obj2;

Modified: team/murf/fast-ast2/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/murf/fast-ast2/main/pbx.c?view=diff&rev=88452&r1=88451&r2=88452
==============================================================================
--- team/murf/fast-ast2/main/pbx.c (original)
+++ team/murf/fast-ast2/main/pbx.c Sat Nov  3 17:24:31 2007
@@ -336,10 +336,10 @@
 static int hashtab_compare_extens(const void *ha_a, const void *ah_b);
 static int hashtab_compare_exten_numbers(const void *ah_a, const void *ah_b);
 static int hashtab_compare_exten_labels(const void *ah_a, const void *ah_b);
-static int hashtab_hash_contexts(const void *obj);
-static int hashtab_hash_extens(const void *obj);
-static int hashtab_hash_priority(const void *obj);
-static int hashtab_hash_labels(const void *obj);
+static unsigned int hashtab_hash_contexts(const void *obj);
+static unsigned int hashtab_hash_extens(const void *obj);
+static unsigned int hashtab_hash_priority(const void *obj);
+static unsigned int hashtab_hash_labels(const void *obj);
 
 /* labels, contexts are case sensitive  priority numbers are ints */
 static int hashtab_compare_contexts(const void *ah_a, const void *ah_b)
@@ -371,25 +371,25 @@
 	return strcmp(ac->label, bc->label);
 }
 
-static int hashtab_hash_contexts(const void *obj)
+static unsigned int hashtab_hash_contexts(const void *obj)
 {
 	const struct ast_context *ac = obj;
 	return ast_hashtab_hash_string(ac->name);
 }
 
-static int hashtab_hash_extens(const void *obj)
+static unsigned int hashtab_hash_extens(const void *obj)
 {
 	const struct ast_exten *ac = obj;
 	return ast_hashtab_hash_string(ac->exten);
 }
 
-static int hashtab_hash_priority(const void *obj)
+static unsigned int hashtab_hash_priority(const void *obj)
 {
 	const struct ast_exten *ac = obj;
 	return ast_hashtab_hash_int(ac->priority);
 }
 
-static int hashtab_hash_labels(const void *obj)
+static unsigned int hashtab_hash_labels(const void *obj)
 {
 	const struct ast_exten *ac = obj;
 	return ast_hashtab_hash_string(ac->label);




More information about the svn-commits mailing list