Asterisk - The Open Source Telephony Project GIT-master-3dae2cf
|
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk. More...
#include "asterisk/lock.h"
Go to the source code of this file.
Data Structures | |
struct | ast_hashtab |
struct | ast_hashtab_bucket |
struct | ast_hashtab_iter |
an iterator for traversing the buckets More... | |
Macros | |
#define | __USE_UNIX98 1 /* to get the MUTEX_RECURSIVE stuff */ |
#define | ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking) _ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Create the hashtable list. More... | |
#define | ast_hashtab_dup(tab, obj_dup_func) _ast_hashtab_dup(tab, obj_dup_func, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_hashtab_insert_immediate(tab, obj) _ast_hashtab_insert_immediate(tab, obj, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Insert without checking. More... | |
#define | ast_hashtab_insert_immediate_bucket(tab, obj, h) _ast_hashtab_insert_immediate_bucket(tab, obj, h, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Insert without checking, hashing or locking. More... | |
#define | ast_hashtab_insert_safe(tab, obj) _ast_hashtab_insert_safe(tab, obj, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_hashtab_start_traversal(tab) _ast_hashtab_start_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define | ast_hashtab_start_write_traversal(tab) _ast_hashtab_start_write_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Functions | |
struct ast_hashtab * | _ast_hashtab_create (int initial_buckets, int(*compare)(const void *a, const void *b), int(*resize)(struct ast_hashtab *), int(*newsize)(struct ast_hashtab *tab), unsigned int(*hash)(const void *obj), int do_locking, const char *file, int lineno, const char *function) |
struct ast_hashtab * | _ast_hashtab_dup (struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func) |
Return a copy of the hash table. More... | |
int | _ast_hashtab_insert_immediate (struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func) |
int | _ast_hashtab_insert_immediate_bucket (struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func) |
int | _ast_hashtab_insert_safe (struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func) |
Check and insert new object only if it is not there. More... | |
struct ast_hashtab_iter * | _ast_hashtab_start_traversal (struct ast_hashtab *tab, const char *file, int lineno, const char *func) |
Gives an iterator to hastable. More... | |
struct ast_hashtab_iter * | _ast_hashtab_start_write_traversal (struct ast_hashtab *tab, const char *file, int lineno, const char *func) |
Gives an iterator to hastable. More... | |
int | ast_hashtab_capacity (struct ast_hashtab *tab) |
Returns the size of the bucket array in the hashtab. More... | |
int | ast_hashtab_compare_ints (const void *a, const void *b) |
Compares two integers for equality. More... | |
int | ast_hashtab_compare_shorts (const void *a, const void *b) |
Compares two shorts for equality. More... | |
int | ast_hashtab_compare_strings (const void *a, const void *b) |
Compares two strings for equality. More... | |
int | ast_hashtab_compare_strings_nocase (const void *a, const void *b) |
Compares two strings for equality, ignoring case. More... | |
void | ast_hashtab_destroy (struct ast_hashtab *tab, void(*objdestroyfunc)(void *obj)) |
This func will free the hash table and all its memory. More... | |
void | ast_hashtab_destroylock (struct ast_hashtab *tab) |
Call this before you destroy the table. More... | |
void | ast_hashtab_end_traversal (struct ast_hashtab_iter *it) |
end the traversal, free the iterator, unlock if necc. More... | |
void | ast_hashtab_get_stats (struct ast_hashtab *tab, int *biggest_bucket_size, int *resize_count, int *num_objects, int *num_buckets) |
Returns key stats for the table. More... | |
unsigned int | ast_hashtab_hash_int (const int num) |
unsigned int | ast_hashtab_hash_short (const short num) |
unsigned int | ast_hashtab_hash_string (const void *obj) |
Hashes a string to a number. More... | |
unsigned int | ast_hashtab_hash_string_nocase (const void *obj) |
Hashes a string to a number ignoring case. More... | |
unsigned int | ast_hashtab_hash_string_sax (const void *obj) |
Hashes a string to a number using a modified Shift-And-XOR algorithm. More... | |
void | ast_hashtab_initlock (struct ast_hashtab *tab) |
Call this after you create the table to init the lock. More... | |
void * | ast_hashtab_lookup (struct ast_hashtab *tab, const void *obj) |
Lookup this object in the hash table. More... | |
void * | ast_hashtab_lookup_bucket (struct ast_hashtab *tab, const void *obj, unsigned int *h) |
Similar to ast_hashtab_lookup but sets h to the key hash value if the lookup fails. More... | |
void * | ast_hashtab_lookup_with_hash (struct ast_hashtab *tab, const void *obj, unsigned int hashval) |
Use this if have the hash val for the object. More... | |
int | ast_hashtab_newsize_java (struct ast_hashtab *tab) |
Create a prime number roughly 2x the current table size. More... | |
int | ast_hashtab_newsize_none (struct ast_hashtab *tab) |
always return current size – no resizing More... | |
int | ast_hashtab_newsize_tight (struct ast_hashtab *tab) |
void * | ast_hashtab_next (struct ast_hashtab_iter *it) |
Gets the next object in the list, advances iter one step returns null on end of traversal. More... | |
void | ast_hashtab_rdlock (struct ast_hashtab *tab) |
Request a read-lock on the table – don't change anything! More... | |
void * | ast_hashtab_remove_object_via_lookup (struct ast_hashtab *tab, void *obj) |
Looks up the object, removes the corresponding bucket. More... | |
void * | ast_hashtab_remove_object_via_lookup_nolock (struct ast_hashtab *tab, void *obj) |
Looks up the object, removes the corresponding bucket. More... | |
void * | ast_hashtab_remove_this_object (struct ast_hashtab *tab, void *obj) |
Hash the object and then compare ptrs in bucket list instead of calling the compare routine, will remove the bucket. More... | |
void * | ast_hashtab_remove_this_object_nolock (struct ast_hashtab *tab, void *obj) |
Hash the object and then compare ptrs in bucket list instead of calling the compare routine, will remove the bucket. More... | |
int | ast_hashtab_resize_java (struct ast_hashtab *tab) |
Determines if a table resize should occur using the Java algorithm (if the table load factor is 75% or higher). More... | |
int | ast_hashtab_resize_none (struct ast_hashtab *tab) |
Effectively disables resizing by always returning 0, regardless of of load factor. More... | |
int | ast_hashtab_resize_tight (struct ast_hashtab *tab) |
Causes a resize whenever the number of elements stored in the table exceeds the number of buckets in the table. More... | |
int | ast_hashtab_size (struct ast_hashtab *tab) |
Returns the number of elements stored in the hashtab. More... | |
void | ast_hashtab_unlock (struct ast_hashtab *tab) |
release a read- or write- lock. More... | |
void | ast_hashtab_wrlock (struct ast_hashtab *tab) |
Request a write-lock on the table. More... | |
int | ast_is_prime (int num) |
Determines if the specified number is prime. More... | |
Generic (perhaps overly so) hashtable implementation Hash Table support in Asterisk.
Definition in file hashtab.h.
#define __USE_UNIX98 1 /* to get the MUTEX_RECURSIVE stuff */ |
#define ast_hashtab_create | ( | initial_buckets, | |
compare, | |||
resize, | |||
newsize, | |||
hash, | |||
do_locking | |||
) | _ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Create the hashtable list.
initial_buckets | starting number of buckets |
compare | a func ptr to compare two elements in the hash – cannot be null |
resize | a func ptr to decide if the table needs to be resized, a NULL ptr here will cause a default to be used |
newsize | a func ptr that returns a new size of the array. A NULL will cause a default to be used |
hash | a func ptr to do the hashing |
do_locking | use locks to guarantee safety of iterators/insertion/deletion – real simpleminded right now |
#define ast_hashtab_dup | ( | tab, | |
obj_dup_func | |||
) | _ast_hashtab_dup(tab, obj_dup_func, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define ast_hashtab_insert_immediate | ( | tab, | |
obj | |||
) | _ast_hashtab_insert_immediate(tab, obj, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Insert without checking.
tab | |
obj |
Normally, you'd insert "safely" by checking to see if the element is already there; in this case, you must already have checked. If an element is already in the hashtable, that matches this one, most likely this one will be found first.
1 | on success |
0 | if there's a problem |
#define ast_hashtab_insert_immediate_bucket | ( | tab, | |
obj, | |||
h | |||
) | _ast_hashtab_insert_immediate_bucket(tab, obj, h, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define ast_hashtab_insert_safe | ( | tab, | |
obj | |||
) | _ast_hashtab_insert_safe(tab, obj, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define ast_hashtab_start_traversal | ( | tab | ) | _ast_hashtab_start_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
#define ast_hashtab_start_write_traversal | ( | tab | ) | _ast_hashtab_start_write_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
struct ast_hashtab * _ast_hashtab_create | ( | int | initial_buckets, |
int(*)(const void *a, const void *b) | compare, | ||
int(*)(struct ast_hashtab *) | resize, | ||
int(*)(struct ast_hashtab *tab) | newsize, | ||
unsigned int(*)(const void *obj) | hash, | ||
int | do_locking, | ||
const char * | file, | ||
int | lineno, | ||
const char * | function | ||
) |
Definition at line 216 of file hashtab.c.
References __ast_calloc(), ast_hashtab::array, ast_free, ast_hashtab_newsize_java(), ast_hashtab_resize_java(), ast_is_prime(), ast_rwlock_init, compare(), ast_hashtab::compare, ast_hashtab::do_locking, make_ari_stubs::file, ast_hashtab::hash, ast_hashtab::hash_tab_size, ast_hashtab::lock, ast_hashtab::newsize, NULL, and ast_hashtab::resize.
struct ast_hashtab * _ast_hashtab_dup | ( | struct ast_hashtab * | tab, |
void *(*)(const void *obj) | obj_dup_func, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Return a copy of the hash table.
Definition at line 261 of file hashtab.c.
References __ast_calloc(), _ast_hashtab_insert_immediate_bucket(), ast_hashtab::array, ast_free, ast_rwlock_init, b, ast_hashtab::compare, ast_hashtab::do_locking, make_ari_stubs::file, ast_hashtab::hash, ast_hashtab::hash_tab_size, ast_hashtab::lock, ast_hashtab::newsize, test_val::next, NULL, and ast_hashtab::resize.
int _ast_hashtab_insert_immediate | ( | struct ast_hashtab * | tab, |
const void * | obj, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 404 of file hashtab.c.
References _ast_hashtab_insert_immediate_bucket(), ast_rwlock_unlock, ast_rwlock_wrlock, ast_hashtab::do_locking, make_ari_stubs::file, ast_hashtab::hash, ast_hashtab::hash_tab_size, and ast_hashtab::lock.
int _ast_hashtab_insert_immediate_bucket | ( | struct ast_hashtab * | tab, |
const void * | obj, | ||
unsigned int | h, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Definition at line 425 of file hashtab.c.
References __ast_calloc(), ast_hashtab::array, ast_hashtab_resize, b, c, make_ari_stubs::file, ast_hashtab::hash_tab_elements, ast_hashtab::largest_bucket_size, test_val::next, ast_hashtab::resize, ast_hashtab::tlist, and tlist_add_head().
Referenced by _ast_hashtab_dup(), _ast_hashtab_insert_immediate(), and _ast_hashtab_insert_safe().
int _ast_hashtab_insert_safe | ( | struct ast_hashtab * | tab, |
const void * | obj, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Check and insert new object only if it is not there.
1 | on success |
0 | if there's a problem, or it's already there. |
Definition at line 460 of file hashtab.c.
References _ast_hashtab_insert_immediate_bucket(), ast_hashtab_lookup_bucket(), ast_rwlock_unlock, ast_rwlock_wrlock, ast_hashtab::do_locking, make_ari_stubs::file, and ast_hashtab::lock.
struct ast_hashtab_iter * _ast_hashtab_start_traversal | ( | struct ast_hashtab * | tab, |
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Gives an iterator to hastable.
Definition at line 637 of file hashtab.c.
References __ast_calloc(), ast_rwlock_rdlock, ast_hashtab::do_locking, make_ari_stubs::file, ast_hashtab::lock, ast_hashtab_iter::next, NULL, ast_hashtab_iter::tab, and ast_hashtab::tlist.
struct ast_hashtab_iter * _ast_hashtab_start_write_traversal | ( | struct ast_hashtab * | tab, |
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
Gives an iterator to hastable.
Definition at line 656 of file hashtab.c.
References __ast_calloc(), ast_rwlock_wrlock, ast_hashtab::do_locking, make_ari_stubs::file, ast_hashtab::lock, ast_hashtab_iter::next, NULL, ast_hashtab_iter::tab, and ast_hashtab::tlist.
int ast_hashtab_capacity | ( | struct ast_hashtab * | tab | ) |
Returns the size of the bucket array in the hashtab.
Definition at line 583 of file hashtab.c.
References ast_hashtab::hash_tab_size.
int ast_hashtab_compare_ints | ( | const void * | a, |
const void * | b | ||
) |
Compares two integers for equality.
a | an integer pointer (int *) |
b | an integer pointer (int *) |
0 | if the integers pointed to are equal |
1 | if a is greater than b |
-1 | if a is less than b |
Definition at line 62 of file hashtab.c.
int ast_hashtab_compare_shorts | ( | const void * | a, |
const void * | b | ||
) |
int ast_hashtab_compare_strings | ( | const void * | a, |
const void * | b | ||
) |
int ast_hashtab_compare_strings_nocase | ( | const void * | a, |
const void * | b | ||
) |
Compares two strings for equality, ignoring case.
a | a character string |
b | a character string |
0 | if the strings match |
negative | if string a is less than string b |
positive | if string a is greater than string b |
Definition at line 57 of file hashtab.c.
Referenced by AST_TEST_DEFINE().
void ast_hashtab_destroy | ( | struct ast_hashtab * | tab, |
void(*)(void *obj) | objdestroyfunc | ||
) |
This func will free the hash table and all its memory.
tab | |
objdestroyfunc |
Definition at line 363 of file hashtab.c.
References ast_hashtab::array, ast_free, ast_rwlock_destroy, ast_rwlock_unlock, ast_rwlock_wrlock, ast_hashtab::do_locking, ast_hashtab::hash_tab_size, ast_hashtab::lock, NULL, ast_hashtab_bucket::object, ast_hashtab::tlist, and tlist_del_item().
Referenced by __ast_internal_context_destroy(), ast_merge_contexts_and_delete(), AST_TEST_DEFINE(), destroy_exten(), pbx_load_module(), and pbx_shutdown().
void ast_hashtab_destroylock | ( | struct ast_hashtab * | tab | ) |
Call this before you destroy the table.
Definition at line 353 of file hashtab.c.
References ast_rwlock_destroy, and ast_hashtab::lock.
void ast_hashtab_end_traversal | ( | struct ast_hashtab_iter * | it | ) |
end the traversal, free the iterator, unlock if necc.
Definition at line 674 of file hashtab.c.
References ast_free, ast_rwlock_unlock, ast_hashtab::do_locking, ast_hashtab::lock, and ast_hashtab_iter::tab.
Referenced by __ast_context_destroy(), ast_merge_contexts_and_delete(), context_merge(), context_table_create_autohints(), create_match_char_tree(), and hash_test_count().
void ast_hashtab_get_stats | ( | struct ast_hashtab * | tab, |
int * | biggest_bucket_size, | ||
int * | resize_count, | ||
int * | num_objects, | ||
int * | num_buckets | ||
) |
Returns key stats for the table.
Definition at line 563 of file hashtab.c.
References ast_rwlock_rdlock, ast_rwlock_unlock, ast_hashtab::do_locking, ast_hashtab::hash_tab_elements, ast_hashtab::hash_tab_size, ast_hashtab::largest_bucket_size, ast_hashtab::lock, and ast_hashtab::resize_count.
Referenced by create_match_char_tree().
unsigned int ast_hashtab_hash_int | ( | const int | num | ) |
Definition at line 205 of file hashtab.c.
Referenced by hashtab_hash_priority().
unsigned int ast_hashtab_hash_short | ( | const short | num | ) |
unsigned int ast_hashtab_hash_string | ( | const void * | obj | ) |
Hashes a string to a number.
obj | the string to hash |
Definition at line 153 of file hashtab.c.
References str, tmp(), and total.
Referenced by ast_hashtab_hash_contexts(), cache_entry_compute_hash(), hashtab_hash_extens(), hashtab_hash_labels(), and stasis_message_type_create().
unsigned int ast_hashtab_hash_string_nocase | ( | const void * | obj | ) |
Hashes a string to a number ignoring case.
obj | the string to hash |
Definition at line 181 of file hashtab.c.
References str, tmp(), and total.
Referenced by AST_TEST_DEFINE(), and hash_string().
unsigned int ast_hashtab_hash_string_sax | ( | const void * | obj | ) |
void ast_hashtab_initlock | ( | struct ast_hashtab * | tab | ) |
Call this after you create the table to init the lock.
Definition at line 348 of file hashtab.c.
References ast_rwlock_init, and ast_hashtab::lock.
void * ast_hashtab_lookup | ( | struct ast_hashtab * | tab, |
const void * | obj | ||
) |
Lookup this object in the hash table.
tab | |
obj |
NULL | if not found |
Definition at line 486 of file hashtab.c.
References ast_hashtab_lookup_internal(), ast_rwlock_rdlock, ast_rwlock_unlock, ast_hashtab::do_locking, ast_hashtab::hash, ast_hashtab::hash_tab_size, and ast_hashtab::lock.
Referenced by ast_add_extension2_lockopt(), ast_context_find(), ast_context_find_or_create(), ast_context_remove_extension_callerid2(), context_merge(), find_context(), find_context_locked(), hash_test_lookup(), and pbx_find_extension().
void * ast_hashtab_lookup_bucket | ( | struct ast_hashtab * | tab, |
const void * | obj, | ||
unsigned int * | h | ||
) |
Similar to ast_hashtab_lookup but sets h to the key hash value if the lookup fails.
Definition at line 531 of file hashtab.c.
References ast_hashtab_lookup_internal(), ast_hashtab::hash, and ast_hashtab::hash_tab_size.
Referenced by _ast_hashtab_insert_safe().
void * ast_hashtab_lookup_with_hash | ( | struct ast_hashtab * | tab, |
const void * | obj, | ||
unsigned int | hashval | ||
) |
Use this if have the hash val for the object.
Definition at line 509 of file hashtab.c.
References ast_hashtab_lookup_internal(), ast_rwlock_rdlock, ast_rwlock_unlock, ast_hashtab::do_locking, ast_hashtab::hash_tab_size, and ast_hashtab::lock.
int ast_hashtab_newsize_java | ( | struct ast_hashtab * | tab | ) |
Create a prime number roughly 2x the current table size.
Definition at line 127 of file hashtab.c.
References ast_is_prime(), and ast_hashtab::hash_tab_size.
Referenced by _ast_hashtab_create(), ast_add_extension2_lockopt(), ast_context_find_or_create(), AST_TEST_DEFINE(), lua_register_hints(), lua_register_switches(), and pbx_load_module().
int ast_hashtab_newsize_none | ( | struct ast_hashtab * | tab | ) |
always return current size – no resizing
Definition at line 148 of file hashtab.c.
References ast_hashtab::hash_tab_size.
int ast_hashtab_newsize_tight | ( | struct ast_hashtab * | tab | ) |
Definition at line 137 of file hashtab.c.
References ast_is_prime(), and ast_hashtab::hash_tab_size.
void * ast_hashtab_next | ( | struct ast_hashtab_iter * | it | ) |
Gets the next object in the list, advances iter one step returns null on end of traversal.
Definition at line 683 of file hashtab.c.
References ast_hashtab_iter::next, NULL, and retval.
Referenced by __ast_context_destroy(), ast_merge_contexts_and_delete(), context_merge(), context_table_create_autohints(), create_match_char_tree(), and hash_test_count().
void ast_hashtab_rdlock | ( | struct ast_hashtab * | tab | ) |
Request a read-lock on the table – don't change anything!
Definition at line 343 of file hashtab.c.
References ast_rwlock_rdlock, and ast_hashtab::lock.
void * ast_hashtab_remove_object_via_lookup | ( | struct ast_hashtab * | tab, |
void * | obj | ||
) |
Looks up the object, removes the corresponding bucket.
Definition at line 746 of file hashtab.c.
References ast_hashtab_remove_object_via_lookup_nolock(), ast_rwlock_unlock, ast_rwlock_wrlock, ast_hashtab::do_locking, and ast_hashtab::lock.
Referenced by add_priority(), and hash_test_shrink().
void * ast_hashtab_remove_object_via_lookup_nolock | ( | struct ast_hashtab * | tab, |
void * | obj | ||
) |
Looks up the object, removes the corresponding bucket.
Definition at line 765 of file hashtab.c.
References ast_hashtab::array, ast_hashtab_remove_object_internal(), b, ast_hashtab::compare, ast_hashtab::hash, ast_hashtab::hash_tab_size, and test_val::next.
Referenced by ast_hashtab_remove_object_via_lookup().
void * ast_hashtab_remove_this_object | ( | struct ast_hashtab * | tab, |
void * | obj | ||
) |
Hash the object and then compare ptrs in bucket list instead of calling the compare routine, will remove the bucket.
Definition at line 789 of file hashtab.c.
References ast_hashtab_remove_this_object_nolock(), ast_rwlock_unlock, ast_rwlock_wrlock, ast_hashtab::do_locking, and ast_hashtab::lock.
Referenced by __ast_context_destroy(), ast_add_extension2_lockopt(), and ast_context_remove_extension_callerid2().
void * ast_hashtab_remove_this_object_nolock | ( | struct ast_hashtab * | tab, |
void * | obj | ||
) |
Hash the object and then compare ptrs in bucket list instead of calling the compare routine, will remove the bucket.
Definition at line 810 of file hashtab.c.
References ast_hashtab::array, ast_hashtab_remove_object_internal(), b, ast_hashtab::hash, ast_hashtab::hash_tab_size, and test_val::next.
Referenced by ast_hashtab_remove_this_object().
int ast_hashtab_resize_java | ( | struct ast_hashtab * | tab | ) |
Determines if a table resize should occur using the Java algorithm (if the table load factor is 75% or higher).
tab | the hash table to operate on |
0 | if the table load factor is less than or equal to 75% |
1 | if the table load factor is greater than 75% |
Definition at line 84 of file hashtab.c.
References ast_hashtab::hash_tab_elements, and ast_hashtab::hash_tab_size.
Referenced by _ast_hashtab_create(), ast_add_extension2_lockopt(), ast_context_find_or_create(), AST_TEST_DEFINE(), lua_register_hints(), lua_register_switches(), and pbx_load_module().
int ast_hashtab_resize_none | ( | struct ast_hashtab * | tab | ) |
int ast_hashtab_resize_tight | ( | struct ast_hashtab * | tab | ) |
Causes a resize whenever the number of elements stored in the table exceeds the number of buckets in the table.
tab | the hash table to operate on |
0 | if the number of elements in the table is less than or equal to the number of buckets |
1 | if the number of elements in the table exceeds the number of buckets |
Definition at line 91 of file hashtab.c.
References ast_hashtab::hash_tab_elements, and ast_hashtab::hash_tab_size.
int ast_hashtab_size | ( | struct ast_hashtab * | tab | ) |
Returns the number of elements stored in the hashtab.
Definition at line 577 of file hashtab.c.
References ast_hashtab::hash_tab_elements.
Referenced by ast_context_remove_extension_callerid2(), and AST_TEST_DEFINE().
void ast_hashtab_unlock | ( | struct ast_hashtab * | tab | ) |
release a read- or write- lock.
Definition at line 358 of file hashtab.c.
References ast_rwlock_unlock, and ast_hashtab::lock.
void ast_hashtab_wrlock | ( | struct ast_hashtab * | tab | ) |
Request a write-lock on the table.
Definition at line 338 of file hashtab.c.
References ast_rwlock_wrlock, and ast_hashtab::lock.
int ast_is_prime | ( | int | num | ) |
Determines if the specified number is prime.
num | the number to test |
0 | if the number is not prime |
1 | if the number is prime |
Definition at line 101 of file hashtab.c.
Referenced by _ast_hashtab_create(), ast_hashtab_newsize_java(), ast_hashtab_newsize_tight(), and sorcery_config_internal_load().