Asterisk - The Open Source Telephony Project
18.5.0
|
code to implement generic hash tables More...
#include "asterisk.h"
#include <ctype.h>
#include "asterisk/lock.h"
#include "asterisk/frame.h"
#include "asterisk/channel.h"
#include "asterisk/cli.h"
#include "asterisk/term.h"
#include "asterisk/utils.h"
#include "asterisk/threadstorage.h"
#include "asterisk/linkedlists.h"
#include "asterisk/hashtab.h"
Go to the source code of this file.
Macros | |
#define | ast_hashtab_resize(tab) _ast_hashtab_resize(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) |
Create the hashtable list. More... | |
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) |
Insert without checking. More... | |
int | _ast_hashtab_insert_immediate_bucket (struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func) |
Insert without checking, hashing or locking. More... | |
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... | |
static void | _ast_hashtab_resize (struct ast_hashtab *tab, const char *file, int lineno, const char *func) |
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 x) |
unsigned int | ast_hashtab_hash_short (const short x) |
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 *bucket) |
Similar to ast_hashtab_lookup but sets h to the key hash value if the lookup fails. More... | |
static void * | ast_hashtab_lookup_internal (struct ast_hashtab *tab, const void *obj, unsigned int h) |
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... | |
static void * | ast_hashtab_remove_object_internal (struct ast_hashtab *tab, struct ast_hashtab_bucket *b, int h) |
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... | |
static void | tlist_add_head (struct ast_hashtab_bucket **head, struct ast_hashtab_bucket *item) |
static void | tlist_del_item (struct ast_hashtab_bucket **head, struct ast_hashtab_bucket *item) |
code to implement generic hash tables
Definition in file hashtab.c.
#define ast_hashtab_resize | ( | tab | ) | _ast_hashtab_resize(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Definition at line 45 of file hashtab.c.
Referenced by _ast_hashtab_insert_immediate_bucket().
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 | ||
) |
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 |
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, ast_hashtab::compare, compare(), ast_hashtab::do_locking, 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, ast_hashtab::compare, ast_hashtab::do_locking, ast_hashtab::hash, ast_hashtab::hash_tab_size, ast_hashtab::lock, ast_hashtab::newsize, ast_hashtab_bucket::next, NULL, ast_hashtab_bucket::object, and ast_hashtab::resize.
int _ast_hashtab_insert_immediate | ( | struct ast_hashtab * | tab, |
const void * | obj, | ||
const char * | file, | ||
int | lineno, | ||
const char * | func | ||
) |
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 |
Definition at line 404 of file hashtab.c.
References _ast_hashtab_insert_immediate_bucket(), ast_rwlock_unlock, ast_rwlock_wrlock, ast_hashtab::do_locking, 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 | ||
) |
Insert without checking, hashing or locking.
tab | |
obj | |
h | hashed index value |
1 | on success |
0 | if there's a problem |
Definition at line 425 of file hashtab.c.
References __ast_calloc(), ast_hashtab::array, ast_hashtab_resize, b, c, ast_hashtab::hash_tab_elements, ast_hashtab::largest_bucket_size, ast_hashtab_bucket::next, ast_hashtab_bucket::object, ast_hashtab_bucket::prev, 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, and ast_hashtab::lock.
|
static |
Definition at line 591 of file hashtab.c.
References __ast_calloc(), ast_hashtab::array, ast_free, b, c, ast_hashtab::hash, ast_hashtab::hash_tab_size, ast_hashtab::largest_bucket_size, ast_hashtab::newsize, ast_hashtab_bucket::next, ast_hashtab_bucket::object, ast_hashtab_bucket::prev, ast_hashtab::resize_count, ast_hashtab::tlist, and ast_hashtab_bucket::tnext.
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, 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, 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 | ||
) |
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 |
<0 | if string a is less than string b |
>0 | if string a is greather 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 | x | ) |
Definition at line 205 of file hashtab.c.
Referenced by hashtab_hash_priority().
unsigned int ast_hashtab_hash_short | ( | const short | x | ) |
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 |
a | ptr if found |
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().
|
static |
Definition at line 549 of file hashtab.c.
References ast_hashtab::array, b, ast_hashtab::compare, ast_hashtab_bucket::next, NULL, and ast_hashtab_bucket::object.
Referenced by ast_hashtab_lookup(), ast_hashtab_lookup_bucket(), and ast_hashtab_lookup_with_hash().
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, ast_hashtab_bucket::object, retval, and ast_hashtab_bucket::tnext.
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.
|
static |
Definition at line 697 of file hashtab.c.
References ast_hashtab::array, ast_free, ast_hashtab::hash_tab_elements, ast_hashtab_bucket::next, ast_hashtab_bucket::object, ast_hashtab_bucket::prev, ast_hashtab::tlist, tlist_del_item(), ast_hashtab_bucket::tnext, and ast_hashtab_bucket::tprev.
Referenced by ast_hashtab_remove_object_via_lookup_nolock(), and ast_hashtab_remove_this_object_nolock().
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, ast_hashtab_bucket::next, and ast_hashtab_bucket::object.
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, ast_hashtab_bucket::next, and ast_hashtab_bucket::object.
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().
|
static |
Definition at line 320 of file hashtab.c.
References item, NULL, ast_hashtab_bucket::tnext, and ast_hashtab_bucket::tprev.
Referenced by _ast_hashtab_insert_immediate_bucket().
|
static |
Definition at line 305 of file hashtab.c.
References NULL, ast_hashtab_bucket::tnext, and ast_hashtab_bucket::tprev.
Referenced by ast_hashtab_destroy(), and ast_hashtab_remove_object_internal().