Asterisk - The Open Source Telephony Project  18.5.0
hashtab.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2006, Digium, Inc.
5  *
6  * Steve Murphy <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 #ifndef _ASTERISK_HASHTAB_H_
19 #define _ASTERISK_HASHTAB_H_
20 #define __USE_UNIX98 1 /* to get the MUTEX_RECURSIVE stuff */
21 
22 /*! \file
23  * \brief Generic (perhaps overly so) hashtable implementation
24  * \ref AstHash
25  */
26 
27 #include "asterisk/lock.h"
28 
29 /*! \page AstHash Hash Table support in Asterisk
30 
31 A hash table is a structure that allows for an exact-match search
32 in O(1) (or close to that) time.
33 
34 The method: given: a set of {key,val} pairs. (at a minimum).
35  given: a hash function, which, given a key,
36  will return an integer. Ideally, each key in the
37  set will have its own unique associated hash value.
38  This hash number will index into an array. "buckets"
39  are what the elements of this array are called. To
40  handle possible collisions in hash values, buckets can form a list.
41 
42 The key for a value must be contained in the value, or we won't
43 be able to find it in the bucket list.
44 
45 This implementation is pretty generic, because:
46 
47  1. The value and key are expected to be in a structure
48  (along with other data, perhaps) and it's address is a "void *".
49  2. The pointer to a compare function must be passed in at the
50  time of creation, and is stored in the hashtable.
51  3. The pointer to a resize function, which returns 1 if the
52  hash table is to be grown. A default routine is provided
53  if the pointer is NULL, and uses the java hashtable metric
54  of a 75% load factor.
55  4. The pointer to a "new size" function, which returns a preferable
56  new size for the hash table bucket array. By default, a function
57  is supplied which roughly doubles the size of the array, is provided.
58  This size should ideally be a prime number.
59  5. The hashing function pointer must also be supplied. This function
60  must be written by the user to access the keys in the objects being
61  stored. Some helper functions that use a simple "mult by prime, add
62  the next char", sort of string hash, or a simple modulus of the hash
63  table size for ints, is provided; the user can use these simple
64  algorithms to generate a hash, or implement any other algorithms they
65  wish.
66  6. Recently updated the hash routines to use Doubly-linked lists for buckets,
67  and added a doubly-linked list that threads thru every bucket in the table.
68  The list of all buckets is on the HashTab struct. The Traversal was modified
69  to go thru this list instead of searching the bucket array for buckets.
70  This also should make it safe to remove a bucket during the traversal.
71  Removal and destruction routines will work faster.
72 */
73 
75 {
76  const void *object; /*!< whatever it is we are storing in this table */
77  struct ast_hashtab_bucket *next; /*!< a DLL of buckets in hash collision */
78  struct ast_hashtab_bucket *prev; /*!< a DLL of buckets in hash collision */
79  struct ast_hashtab_bucket *tnext; /*!< a DLL of all the hash buckets for traversal */
80  struct ast_hashtab_bucket *tprev; /*!< a DLL of all the hash buckets for traversal */
81 };
82 
84 {
86  struct ast_hashtab_bucket *tlist; /*!< the head of a DLList of all the hashbuckets in the table (for traversal). */
87 
88  int (*compare) (const void *a, const void *b); /*!< a ptr to func that returns int, and take two void* ptrs, compares them,
89  rets -1 if a < b; rets 0 if a==b; rets 1 if a>b */
90  int (*newsize) (struct ast_hashtab *tab); /*!< a ptr to func that returns int, a new size for hash tab, based on curr_size */
91  int (*resize) (struct ast_hashtab *tab); /*!< a function to decide whether this hashtable should be resized now */
92  unsigned int (*hash) (const void *obj); /*!< a hash func ptr for this table. Given a raw ptr to an obj,
93  it calcs a hash.*/
94  int hash_tab_size; /*!< the size of the bucket array */
95  int hash_tab_elements; /*!< the number of objects currently stored in the table */
96  int largest_bucket_size; /*!< a stat on the health of the table */
97  int resize_count; /*!< a count of the number of times this table has been
98  resized */
99  int do_locking; /*!< if 1 use locks to guarantee safety of insertions/deletions */
100  /* this spot reserved for the proper lock storage */
101  ast_rwlock_t lock; /* is this as good as it sounds? */
102 };
103 
104 /*! \brief an iterator for traversing the buckets */
106 {
107  struct ast_hashtab *tab;
109 };
110 
111 
112 /* some standard, default routines for general use */
113 
114 /*!
115  * \brief Determines if the specified number is prime.
116  *
117  * \param num the number to test
118  * \retval 0 if the number is not prime
119  * \retval 1 if the number is prime
120  */
121 int ast_is_prime(int num);
122 
123 /*!
124  * \brief Compares two strings for equality.
125  *
126  * \param a a character string
127  * \param b a character string
128  * \retval 0 if the strings match
129  * \retval <0 if string a is less than string b
130  * \retval >0 if string a is greather than string b
131  */
132 int ast_hashtab_compare_strings(const void *a, const void *b);
133 
134 /*!
135  * \brief Compares two strings for equality, ignoring case.
136  *
137  * \param a a character string
138  * \param b a character string
139  * \retval 0 if the strings match
140  * \retval <0 if string a is less than string b
141  * \retval >0 if string a is greather than string b
142  */
143 int ast_hashtab_compare_strings_nocase(const void *a, const void *b);
144 
145 /*!
146  * \brief Compares two integers for equality.
147  *
148  * \param a an integer pointer (int *)
149  * \param b an integer pointer (int *)
150  * \retval 0 if the integers pointed to are equal
151  * \retval 1 if a is greater than b
152  * \retval -1 if a is less than b
153  */
154 int ast_hashtab_compare_ints(const void *a, const void *b);
155 
156 /*!
157  * \brief Compares two shorts for equality.
158  *
159  * \param a a short pointer (short *)
160  * \param b a short pointer (short *)
161  * \retval 0 if the shorts pointed to are equal
162  * \retval 1 if a is greater than b
163  * \retval -1 if a is less than b
164  */
165 int ast_hashtab_compare_shorts(const void *a, const void *b);
166 
167 /*!
168  * \brief Determines if a table resize should occur using the Java algorithm
169  * (if the table load factor is 75% or higher).
170  *
171  * \param tab the hash table to operate on
172  * \retval 0 if the table load factor is less than or equal to 75%
173  * \retval 1 if the table load factor is greater than 75%
174  */
175 int ast_hashtab_resize_java(struct ast_hashtab *tab);
176 
177 /*! \brief Causes a resize whenever the number of elements stored in the table
178  * exceeds the number of buckets in the table.
179  *
180  * \param tab the hash table to operate on
181  * \retval 0 if the number of elements in the table is less than or equal to
182  * the number of buckets
183  * \retval 1 if the number of elements in the table exceeds the number of
184  * buckets
185  */
186 int ast_hashtab_resize_tight(struct ast_hashtab *tab);
187 
188 /*!
189  * \brief Effectively disables resizing by always returning 0, regardless of
190  * of load factor.
191  *
192  * \param tab the hash table to operate on
193  * \return 0 is always returned
194  */
195 int ast_hashtab_resize_none(struct ast_hashtab *tab);
196 
197 /*! \brief Create a prime number roughly 2x the current table size */
198 int ast_hashtab_newsize_java(struct ast_hashtab *tab);
199 
200 /* not yet specified, probably will return 1.5x the current table size */
201 int ast_hashtab_newsize_tight(struct ast_hashtab *tab);
202 
203 /*! \brief always return current size -- no resizing */
204 int ast_hashtab_newsize_none(struct ast_hashtab *tab);
205 
206 /*!
207  * \brief Hashes a string to a number
208  *
209  * \param obj the string to hash
210  * \return Integer hash of the specified string
211  * \sa ast_hashtable_hash_string_nocase
212  * \sa ast_hashtab_hash_string_sax
213  * \note A modulus will be applied to the return value of this function
214  */
215 unsigned int ast_hashtab_hash_string(const void *obj);
216 
217 /*!
218  * \brief Hashes a string to a number ignoring case
219  *
220  * \param obj the string to hash
221  * \return Integer hash of the specified string
222  * \sa ast_hashtable_hash_string
223  * \sa ast_hashtab_hash_string_sax
224  * \note A modulus will be applied to the return value of this function
225  */
226 unsigned int ast_hashtab_hash_string_nocase(const void *obj);
227 
228 /*!
229  * \brief Hashes a string to a number using a modified Shift-And-XOR algorithm
230  *
231  * \param obj the string to hash
232  * \return Integer has of the specified string
233  * \sa ast_hastable_hash_string
234  * \sa ast_hastable_hash_string_nocase
235  */
236 unsigned int ast_hashtab_hash_string_sax(const void *obj);
237 
238 
239 unsigned int ast_hashtab_hash_int(const int num); /* right now, both these funcs are just result = num%modulus; */
240 
241 
242 unsigned int ast_hashtab_hash_short(const short num);
243 
244 
245 /*!
246  * \brief Create the hashtable list
247  * \param initial_buckets starting number of buckets
248  * \param compare a func ptr to compare two elements in the hash -- cannot be null
249  * \param resize a func ptr to decide if the table needs to be resized, a NULL ptr here will cause a default to be used
250  * \param newsize a func ptr that returns a new size of the array. A NULL will cause a default to be used
251  * \param hash a func ptr to do the hashing
252  * \param do_locking use locks to guarantee safety of iterators/insertion/deletion -- real simpleminded right now
253 */
254 struct ast_hashtab *_ast_hashtab_create(int initial_buckets,
255  int (*compare)(const void *a, const void *b),
256  int (*resize)(struct ast_hashtab *),
257  int (*newsize)(struct ast_hashtab *tab),
258  unsigned int (*hash)(const void *obj),
259  int do_locking,
260  const char *file, int lineno, const char *function);
261 #define ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking) \
262  _ast_hashtab_create(initial_buckets, compare, resize, newsize, hash, do_locking, __FILE__, __LINE__, __PRETTY_FUNCTION__)
263 
264 /*!
265  * \brief This func will free the hash table and all its memory.
266  * \note It doesn't touch the objects stored in it, unless you
267  * specify a destroy func; it will call that func for each
268  * object in the hashtab, remove all the objects, and then
269  * free the hashtab itself. If no destroyfunc is specified
270  * then the routine will assume you will free it yourself.
271  * \param tab
272  * \param objdestroyfunc
273 */
274 void ast_hashtab_destroy( struct ast_hashtab *tab, void (*objdestroyfunc)(void *obj));
275 
276 
277 /*!
278  * \brief Insert without checking
279  * \param tab
280  * \param obj
281  *
282  * Normally, you'd insert "safely" by checking to see if the element is
283  * already there; in this case, you must already have checked. If an element
284  * is already in the hashtable, that matches this one, most likely this one
285  * will be found first.
286  * \note will force a resize if the resize func returns 1
287  * \retval 1 on success
288  * \retval 0 if there's a problem
289 */
290 int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func);
291 #define ast_hashtab_insert_immediate(tab, obj) \
292  _ast_hashtab_insert_immediate(tab, obj, __FILE__, __LINE__, __PRETTY_FUNCTION__)
293 
294 /*!
295  * \brief Insert without checking, hashing or locking
296  * \param tab
297  * \param obj
298  * \param h hashed index value
299  *
300  * \note Will force a resize if the resize func returns 1
301  * \retval 1 on success
302  * \retval 0 if there's a problem
303 */
304 int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func);
305 #define ast_hashtab_insert_immediate_bucket(tab, obj, h) \
306  _ast_hashtab_insert_immediate_bucket(tab, obj, h, __FILE__, __LINE__, __PRETTY_FUNCTION__)
307 
308 /*!
309  * \brief Check and insert new object only if it is not there.
310  * \note Will force a resize if the resize func returns 1
311  * \retval 1 on success
312  * \retval 0 if there's a problem, or it's already there.
313 */
314 int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func);
315 #define ast_hashtab_insert_safe(tab, obj) \
316  _ast_hashtab_insert_safe(tab, obj, __FILE__, __LINE__, __PRETTY_FUNCTION__)
317 
318 /*!
319  * \brief Lookup this object in the hash table.
320  * \param tab
321  * \param obj
322  * \retval a ptr if found
323  * \retval NULL if not found
324 */
325 void * ast_hashtab_lookup(struct ast_hashtab *tab, const void *obj);
326 
327 /*!
328  * \brief Use this if have the hash val for the object
329  * \note This and avoid the recalc of the hash (the modulus (table_size) is not applied)
330 */
331 void * ast_hashtab_lookup_with_hash(struct ast_hashtab *tab, const void *obj, unsigned int hashval);
332 
333 /*!
334  * \brief Similar to ast_hashtab_lookup but sets h to the key hash value if the lookup fails.
335  * \note This has the modulus applied, and will not be useful for long term storage if the table is resizable.
336 */
337 void * ast_hashtab_lookup_bucket(struct ast_hashtab *tab, const void *obj, unsigned int *h);
338 
339 /*! \brief Returns key stats for the table */
340 void ast_hashtab_get_stats( struct ast_hashtab *tab, int *biggest_bucket_size, int *resize_count, int *num_objects, int *num_buckets);
341 
342 /*! \brief Returns the number of elements stored in the hashtab */
343 int ast_hashtab_size( struct ast_hashtab *tab);
344 
345 /*! \brief Returns the size of the bucket array in the hashtab */
346 int ast_hashtab_capacity( struct ast_hashtab *tab);
347 
348 /*! \brief Return a copy of the hash table */
349 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);
350 #define ast_hashtab_dup(tab, obj_dup_func) \
351  _ast_hashtab_dup(tab, obj_dup_func, __FILE__, __LINE__, __PRETTY_FUNCTION__)
352 
353 /*! \brief Gives an iterator to hastable */
354 struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
355 #define ast_hashtab_start_traversal(tab) \
356  _ast_hashtab_start_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__)
357 
358 /*! \brief end the traversal, free the iterator, unlock if necc. */
360 
361 /*! \brief Gets the next object in the list, advances iter one step returns null on end of traversal */
362 void *ast_hashtab_next(struct ast_hashtab_iter *it);
363 
364 /*! \brief Looks up the object, removes the corresponding bucket */
365 void *ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, void *obj);
366 
367 /*! \brief Hash the object and then compare ptrs in bucket list instead of
368  calling the compare routine, will remove the bucket */
369 void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj);
370 
371 /* ------------------ */
372 /* for lock-enabled traversals with ability to remove an object during the traversal*/
373 /* ------------------ */
374 
375 /*! \brief Gives an iterator to hastable */
376 struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func);
377 #define ast_hashtab_start_write_traversal(tab) \
378  _ast_hashtab_start_write_traversal(tab, __FILE__, __LINE__, __PRETTY_FUNCTION__)
379 
380 /*! \brief Looks up the object, removes the corresponding bucket */
381 void *ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, void *obj);
382 
383 /*! \brief Hash the object and then compare ptrs in bucket list instead of
384  calling the compare routine, will remove the bucket */
385 void *ast_hashtab_remove_this_object_nolock(struct ast_hashtab *tab, void *obj);
386 
387 /* ------------------ */
388 /* ------------------ */
389 
390 /* user-controlled hashtab locking. Create a hashtab without locking, then call the
391  following locking routines yourself to lock the table between threads. */
392 
393 /*! \brief Call this after you create the table to init the lock */
394 void ast_hashtab_initlock(struct ast_hashtab *tab);
395 /*! \brief Request a write-lock on the table. */
396 void ast_hashtab_wrlock(struct ast_hashtab *tab);
397 /*! \brief Request a read-lock on the table -- don't change anything! */
398 void ast_hashtab_rdlock(struct ast_hashtab *tab);
399 /*! \brief release a read- or write- lock. */
400 void ast_hashtab_unlock(struct ast_hashtab *tab);
401 /*! \brief Call this before you destroy the table. */
402 void ast_hashtab_destroylock(struct ast_hashtab *tab);
403 
404 
405 #endif
struct ast_hashtab_bucket * tnext
Definition: hashtab.h:79
int ast_hashtab_resize_none(struct ast_hashtab *tab)
Effectively disables resizing by always returning 0, regardless of of load factor.
Definition: hashtab.c:96
int ast_hashtab_capacity(struct ast_hashtab *tab)
Returns the size of the bucket array in the hashtab.
Definition: hashtab.c:583
Asterisk locking-related definitions:
int ast_hashtab_compare_strings_nocase(const void *a, const void *b)
Compares two strings for equality, ignoring case.
Definition: hashtab.c:57
void * ast_hashtab_lookup(struct ast_hashtab *tab, const void *obj)
Lookup this object in the hash table.
Definition: hashtab.c:486
int ast_hashtab_newsize_java(struct ast_hashtab *tab)
Create a prime number roughly 2x the current table size.
Definition: hashtab.c:127
int hash_tab_size
Definition: hashtab.h:94
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...
Definition: hashtab.c:810
int largest_bucket_size
Definition: hashtab.h:96
void ast_hashtab_destroylock(struct ast_hashtab *tab)
Call this before you destroy the table.
Definition: hashtab.c:353
ast_rwlock_t lock
Definition: hashtab.h:101
int ast_hashtab_newsize_none(struct ast_hashtab *tab)
always return current size – no resizing
Definition: hashtab.c:148
struct ast_hashtab_bucket * tprev
Definition: hashtab.h:80
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.
Definition: hashtab.c:261
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: hashtab.c:683
int resize_count
Definition: hashtab.h:97
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 ...
Definition: hashtab.c:91
struct ast_hashtab_bucket * prev
Definition: hashtab.h:78
int ast_hashtab_compare_ints(const void *a, const void *b)
Compares two integers for equality.
Definition: hashtab.c:62
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: hashtab.c:637
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.
Definition: hashtab.c:425
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% o...
Definition: hashtab.c:84
struct ast_hashtab_bucket * next
Definition: hashtab.h:108
void * ast_hashtab_remove_object_via_lookup_nolock(struct ast_hashtab *tab, void *obj)
Looks up the object, removes the corresponding bucket.
Definition: hashtab.c:765
int do_locking
Definition: hashtab.h:99
unsigned int ast_hashtab_hash_string_sax(const void *obj)
Hashes a string to a number using a modified Shift-And-XOR algorithm.
Definition: hashtab.c:170
void ast_hashtab_end_traversal(struct ast_hashtab_iter *it)
end the traversal, free the iterator, unlock if necc.
Definition: hashtab.c:674
struct ast_hashtab_bucket ** array
Definition: hashtab.h:85
struct ast_hashtab * tab
Definition: hashtab.h:107
void * ast_hashtab_remove_object_via_lookup(struct ast_hashtab *tab, void *obj)
Looks up the object, removes the corresponding bucket.
Definition: hashtab.c:746
int ast_hashtab_compare_shorts(const void *a, const void *b)
Compares two shorts for equality.
Definition: hashtab.c:73
int(* resize)(struct ast_hashtab *tab)
Definition: hashtab.h:91
struct ast_hashtab_bucket * tlist
Definition: hashtab.h:86
void ast_hashtab_rdlock(struct ast_hashtab *tab)
Request a read-lock on the table – don&#39;t change anything!
Definition: hashtab.c:343
an iterator for traversing the buckets
Definition: hashtab.h:105
void ast_hashtab_wrlock(struct ast_hashtab *tab)
Request a write-lock on the table.
Definition: hashtab.c:338
int ast_hashtab_newsize_tight(struct ast_hashtab *tab)
Definition: hashtab.c:137
unsigned int ast_hashtab_hash_string(const void *obj)
Hashes a string to a number.
Definition: hashtab.c:153
unsigned int(* hash)(const void *obj)
Definition: hashtab.h:92
int ast_hashtab_compare_strings(const void *a, const void *b)
Compares two strings for equality.
Definition: hashtab.c:52
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: hashtab.c:656
unsigned int ast_hashtab_hash_int(const int num)
Definition: hashtab.c:205
const void * object
Definition: hashtab.h:76
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: hashtab.c:531
Structure for rwlock and tracking information.
Definition: lock.h:156
struct ast_hashtab_bucket * next
Definition: hashtab.h:77
static int compare(const char *text, const char *template)
void ast_hashtab_initlock(struct ast_hashtab *tab)
Call this after you create the table to init the lock.
Definition: hashtab.c:348
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.
Definition: hashtab.c:460
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: hashtab.c:509
static struct test_val b
unsigned int ast_hashtab_hash_string_nocase(const void *obj)
Hashes a string to a number ignoring case.
Definition: hashtab.c:181
int(* newsize)(struct ast_hashtab *tab)
Definition: hashtab.h:90
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.
Definition: hashtab.c:216
int ast_hashtab_size(struct ast_hashtab *tab)
Returns the number of elements stored in the hashtab.
Definition: hashtab.c:577
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: hashtab.c:563
unsigned int ast_hashtab_hash_short(const short num)
Definition: hashtab.c:210
int ast_is_prime(int num)
Determines if the specified number is prime.
Definition: hashtab.c:101
int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func)
Insert without checking.
Definition: hashtab.c:404
void ast_hashtab_unlock(struct ast_hashtab *tab)
release a read- or write- lock.
Definition: hashtab.c:358
int hash_tab_elements
Definition: hashtab.h:95
void ast_hashtab_destroy(struct ast_hashtab *tab, void(*objdestroyfunc)(void *obj))
This func will free the hash table and all its memory.
Definition: hashtab.c:363
static struct test_val a
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...
Definition: hashtab.c:789