Asterisk - The Open Source Telephony Project
18.5.0
|
Hash table functions implementing astobj2 containers. More...
#include "asterisk.h"
#include "asterisk/_private.h"
#include "asterisk/astobj2.h"
#include "astobj2_private.h"
#include "astobj2_container_private.h"
#include "asterisk/dlinkedlists.h"
#include "asterisk/utils.h"
Go to the source code of this file.
Data Structures | |
struct | ao2_container_hash |
struct | hash_bucket |
struct | hash_bucket_node |
struct | hash_traversal_state |
struct | hash_traversal_state_check |
Functions | |
struct ao2_container * | __ao2_container_alloc_hash (unsigned int ao2_options, unsigned int container_options, unsigned int n_buckets, ao2_hash_fn *hash_fn, ao2_sort_fn *sort_fn, ao2_callback_fn *cmp_fn, const char *tag, const char *file, int line, const char *func) |
struct ao2_container * | __ao2_container_alloc_list (unsigned int ao2_options, unsigned int container_options, ao2_sort_fn *sort_fn, ao2_callback_fn *cmp_fn, const char *tag, const char *file, int line, const char *func) |
static struct ao2_container * | hash_ao2_alloc_empty_clone (struct ao2_container_hash *self, const char *tag, const char *file, int line, const char *func) |
static struct ao2_container * | hash_ao2_container_init (struct ao2_container_hash *self, unsigned int options, unsigned int n_buckets, ao2_hash_fn *hash_fn, ao2_sort_fn *sort_fn, ao2_callback_fn *cmp_fn) |
Initialize a hash container with the desired number of buckets. More... | |
static void | hash_ao2_destroy (struct ao2_container_hash *self) |
static struct hash_bucket_node * | hash_ao2_find_first (struct ao2_container_hash *self, enum search_flags flags, void *arg, struct hash_traversal_state *state) |
static struct hash_bucket_node * | hash_ao2_find_next (struct ao2_container_hash *self, struct hash_traversal_state *state, struct hash_bucket_node *prev) |
static enum ao2_container_insert | hash_ao2_insert_node (struct ao2_container_hash *self, struct hash_bucket_node *node) |
static struct hash_bucket_node * | hash_ao2_iterator_next (struct ao2_container_hash *self, struct hash_bucket_node *node, enum ao2_iterator_flags flags) |
static struct hash_bucket_node * | hash_ao2_new_node (struct ao2_container_hash *self, void *obj_new, const char *tag, const char *file, int line, const char *func) |
static void | hash_ao2_node_destructor (void *v_doomed) |
static int | hash_zero (const void *user_obj, const int flags) |
always zero hash function More... | |
Variables | |
static const struct ao2_container_methods | v_table_hash |
Hash table functions implementing astobj2 containers.
Definition in file astobj2_hash.c.
struct ao2_container* __ao2_container_alloc_hash | ( | unsigned int | ao2_options, |
unsigned int | container_options, | ||
unsigned int | n_buckets, | ||
ao2_hash_fn * | hash_fn, | ||
ao2_sort_fn * | sort_fn, | ||
ao2_callback_fn * | cmp_fn, | ||
const char * | tag, | ||
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Definition at line 1079 of file astobj2_hash.c.
References __ao2_alloc(), container_destruct(), hash_ao2_container_init(), and ao2_container_hash::n_buckets.
Referenced by __ao2_container_alloc_list(), and hash_ao2_alloc_empty_clone().
struct ao2_container* __ao2_container_alloc_list | ( | unsigned int | ao2_options, |
unsigned int | container_options, | ||
ao2_sort_fn * | sort_fn, | ||
ao2_callback_fn * | cmp_fn, | ||
const char * | tag, | ||
const char * | file, | ||
int | line, | ||
const char * | func | ||
) |
Definition at line 1097 of file astobj2_hash.c.
References __ao2_container_alloc_hash(), and NULL.
|
static |
Definition at line 116 of file astobj2_hash.c.
References __ao2_container_alloc_hash(), __is_ao2_object, ao2_options_get(), and NULL.
|
static |
Initialize a hash container with the desired number of buckets.
self | Container to initialize. |
options | Container behaviour options (See enum ao2_container_opts) |
n_buckets | Number of buckets for hash |
hash_fn | Pointer to a function computing a hash value. |
sort_fn | Pointer to a sort function. |
cmp_fn | Pointer to a compare function used by ao2_find. |
Definition at line 1057 of file astobj2_hash.c.
References ast_atomic_fetchadd_int(), ao2_container::cmp_fn, hash_zero(), NULL, options, ao2_container::sort_fn, and v_table_hash.
Referenced by __ao2_container_alloc_hash().
|
static |
Definition at line 739 of file astobj2_hash.c.
References abs, ao2_container_count(), ast_assert, AST_DLLIST_EMPTY, AST_DLLIST_FIRST, AST_DLLIST_LAST, AST_DLLIST_NEXT, AST_DLLIST_PREV, ast_log, hash_bucket_node::common, FORMAT, FORMAT2, hash_bucket_node::links, LOG_ERROR, hash_bucket_node::my_bucket, NULL, ao2_container_node::obj, and OBJ_SEARCH_OBJECT.
|
static |
Definition at line 335 of file astobj2_hash.c.
References abs, ao2_ref, hash_traversal_state::arg, AST_DLLIST_FIRST, AST_DLLIST_LAST, AST_DLLIST_NEXT, AST_DLLIST_PREV, hash_traversal_state::bucket_last, hash_traversal_state::bucket_start, hash_bucket_node::common, hash_traversal_state::descending, hash_traversal_state::flags, hash_bucket_node::links, NULL, ao2_container_node::obj, OBJ_ORDER_ASCENDING, OBJ_ORDER_DESCENDING, OBJ_ORDER_MASK, OBJ_ORDER_POST, OBJ_ORDER_PRE, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, OBJ_SEARCH_PARTIAL_KEY, and hash_traversal_state::sort_fn.
|
static |
Definition at line 483 of file astobj2_hash.c.
References ao2_ref, hash_traversal_state::arg, AST_DLLIST_FIRST, AST_DLLIST_LAST, AST_DLLIST_NEXT, AST_DLLIST_PREV, hash_traversal_state::bucket_last, hash_bucket_node::common, hash_traversal_state::descending, hash_traversal_state::flags, hash_bucket_node::links, hash_bucket_node::my_bucket, NULL, ao2_container_node::obj, OBJ_SEARCH_MASK, and hash_traversal_state::sort_fn.
|
static |
Definition at line 239 of file astobj2_hash.c.
References AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW, AO2_CONTAINER_ALLOC_OPT_DUPS_MASK, AO2_CONTAINER_ALLOC_OPT_DUPS_OBJ_REJECT, AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, AO2_CONTAINER_ALLOC_OPT_DUPS_REPLACE, AO2_CONTAINER_ALLOC_OPT_INSERT_BEGIN, AO2_CONTAINER_INSERT_NODE_INSERTED, AO2_CONTAINER_INSERT_NODE_OBJ_REPLACED, AO2_CONTAINER_INSERT_NODE_REJECTED, ao2_ref, AST_DLLIST_INSERT_AFTER_CURRENT, AST_DLLIST_INSERT_BEFORE_CURRENT, AST_DLLIST_INSERT_HEAD, AST_DLLIST_INSERT_TAIL, AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_BEGIN, AST_DLLIST_TRAVERSE_BACKWARDS_SAFE_END, AST_DLLIST_TRAVERSE_SAFE_BEGIN, AST_DLLIST_TRAVERSE_SAFE_END, hash_bucket_node::common, hash_bucket_node::links, hash_bucket::list, hash_bucket_node::my_bucket, ao2_container_node::obj, OBJ_SEARCH_OBJECT, options, and SWAP.
|
static |
Definition at line 613 of file astobj2_hash.c.
References AO2_ITERATOR_DESCENDING, AST_DLLIST_FIRST, AST_DLLIST_LAST, AST_DLLIST_NEXT, AST_DLLIST_PREV, hash_bucket_node::common, hash_bucket_node::links, hash_bucket_node::my_bucket, NULL, and ao2_container_node::obj.
|
static |
Definition at line 208 of file astobj2_hash.c.
References __ao2_ref(), abs, AO2_ALLOC_OPT_LOCK_NOLOCK, AO2_ALLOC_OPT_NO_REF_DEBUG, ao2_alloc_options, hash_bucket_node::common, hash_ao2_node_destructor(), hash_bucket_node::my_bucket, ao2_container_node::my_container, NULL, ao2_container_node::obj, and OBJ_SEARCH_OBJECT.
|
static |
Definition at line 145 of file astobj2_hash.c.
References __adjust_lock(), __container_unlink_node, ao2_container_check(), AO2_DEVMODE_STAT, AO2_LOCK_REQ_WRLOCK, AO2_UNLINK_NODE_UNLINK_OBJECT, AST_DEVMODE, AST_DLLIST_REMOVE, ast_log, ao2_container_hash::buckets, ao2_container_hash::common, hash_bucket_node::common, ao2_container::destroying, is_ao2_object, ao2_container_node::is_linked, hash_bucket_node::links, hash_bucket::list, LOG_ERROR, hash_bucket_node::my_bucket, ao2_container_node::my_container, ao2_container_node::obj, and OBJ_NOLOCK.
Referenced by hash_ao2_new_node().
|
static |
always zero hash function
it is convenient to have a hash function that always returns 0. This is basically used when we want to have a container that is a simple linked list.
Definition at line 1040 of file astobj2_hash.c.
Referenced by hash_ao2_container_init().
|
static |
Hash container virtual method table.
Definition at line 1014 of file astobj2_hash.c.
Referenced by hash_ao2_container_init().