17 #ifndef _ASTERISK_ASTOBJ2_H 18 #define _ASTERISK_ASTOBJ2_H 404 #define ao2_t_alloc_options(data_size, destructor_fn, options, debug_msg) \ 405 __ao2_alloc((data_size), (destructor_fn), (options), (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__) 406 #define ao2_alloc_options(data_size, destructor_fn, options) \ 407 __ao2_alloc((data_size), (destructor_fn), (options), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 409 #define ao2_t_alloc(data_size, destructor_fn, debug_msg) \ 410 __ao2_alloc((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX, (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__) 411 #define ao2_alloc(data_size, destructor_fn) \ 412 __ao2_alloc((data_size), (destructor_fn), AO2_ALLOC_OPT_LOCK_MUTEX, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 433 #define ao2_alloc_with_lockobj(data_size, destructor_fn, lockobj, tag) \ 434 __ao2_alloc_with_lockobj((data_size), (destructor_fn), (lockobj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 463 #define ao2_t_ref(o,delta,tag) __ao2_ref((o), (delta), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 464 #define ao2_ref(o,delta) __ao2_ref((o), (delta), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 483 #define ao2_t_bump(obj, tag) \ 485 typeof(obj) __obj_ ## __LINE__ = (obj); \ 486 if (__obj_ ## __LINE__) { \ 487 ao2_t_ref(__obj_ ## __LINE__, +1, (tag)); \ 489 __obj_ ## __LINE__; \ 491 #define ao2_bump(obj) \ 492 ao2_t_bump((obj), NULL) 494 int __ao2_ref(
void *o,
int delta,
const char *tag,
const char *
file,
int line,
const char *func);
503 #define ao2_t_replace(dst, src, tag) \ 505 typeof(dst) *__dst_ ## __LINE__ = &dst; \ 506 typeof(src) __src_ ## __LINE__ = src; \ 507 if (__src_ ## __LINE__ != *__dst_ ## __LINE__) { \ 508 if (__src_ ## __LINE__) {\ 509 ao2_t_ref(__src_ ## __LINE__, +1, (tag)); \ 511 if (*__dst_ ## __LINE__) {\ 512 ao2_t_ref(*__dst_ ## __LINE__, -1, (tag)); \ 514 *__dst_ ## __LINE__ = __src_ ## __LINE__; \ 517 #define ao2_replace(dst, src) \ 518 ao2_t_replace((dst), (src), NULL) 539 #define AO2_WEAKPROXY() struct ao2_weakproxy __weakproxy##__LINE__ 554 #define ao2_weakproxy_alloc(data_size, destructor_fn) \ 555 __ao2_weakproxy_alloc(data_size, destructor_fn, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 557 #define ao2_t_weakproxy_alloc(data_size, destructor_fn, tag) \ 558 __ao2_weakproxy_alloc(data_size, destructor_fn, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) 581 const char *tag,
const char *
file,
int line,
const char *func);
583 #define ao2_weakproxy_set_object(weakproxy, obj, flags) \ 584 __ao2_weakproxy_set_object(weakproxy, obj, flags, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 586 #define ao2_t_weakproxy_set_object(weakproxy, obj, flags, tag) \ 587 __ao2_weakproxy_set_object(weakproxy, obj, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) 603 const char *tag,
const char *
file,
int line,
const char *func);
605 #define ao2_t_weakproxy_ref_object(weakproxy, delta, flags, tag) \ 606 __ao2_weakproxy_ref_object(weakproxy, delta, flags, \ 607 tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) 609 #define ao2_weakproxy_ref_object(weakproxy, delta, flags) \ 610 ao2_t_weakproxy_ref_object(weakproxy, delta, flags, NULL) 625 #define ao2_weakproxy_get_object(weakproxy, flags) \ 626 __ao2_weakproxy_get_object(weakproxy, flags, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 628 #define ao2_t_weakproxy_get_object(weakproxy, flags, tag) \ 629 __ao2_weakproxy_get_object(weakproxy, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) 692 #define ao2_get_weakproxy(obj) \ 693 __ao2_get_weakproxy(obj, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 695 #define ao2_t_get_weakproxy(obj, tag) \ 696 __ao2_get_weakproxy(obj, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) 718 #define ao2_lock(a) __ao2_lock(a, AO2_LOCK_REQ_MUTEX, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) 719 #define ao2_rdlock(a) __ao2_lock(a, AO2_LOCK_REQ_RDLOCK, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) 720 #define ao2_wrlock(a) __ao2_lock(a, AO2_LOCK_REQ_WRLOCK, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) 730 #define ao2_unlock(a) __ao2_unlock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) 740 #define ao2_trylock(a) __ao2_trylock(a, AO2_LOCK_REQ_MUTEX, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) 741 #define ao2_tryrdlock(a) __ao2_trylock(a, AO2_LOCK_REQ_RDLOCK, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) 742 #define ao2_trywrlock(a) __ao2_trylock(a, AO2_LOCK_REQ_WRLOCK, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a) 830 #ifndef HAVE_PTHREAD_RWLOCK_INITIALIZER 831 #define AO2_GLOBAL_OBJ_STATIC(name) \ 832 struct ao2_global_obj name; \ 833 static void __attribute__((constructor)) __init_##name(void) \ 835 ast_rwlock_init(&name.lock); \ 838 static void __attribute__((destructor)) __fini_##name(void) \ 841 ao2_ref(name.obj, -1); \ 844 ast_rwlock_destroy(&name.lock); \ 846 struct __dummy_##name 848 #define AO2_GLOBAL_OBJ_STATIC(name) \ 849 struct ao2_global_obj name = { \ 850 .lock = AST_RWLOCK_INIT_VALUE, \ 863 #define ao2_t_global_obj_release(holder, tag) \ 864 __ao2_global_obj_replace_unref(&holder, NULL, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) 865 #define ao2_global_obj_release(holder) \ 866 __ao2_global_obj_replace_unref(&holder, NULL, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) 883 #define ao2_t_global_obj_replace(holder, obj, tag) \ 884 __ao2_global_obj_replace(&holder, (obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) 885 #define ao2_global_obj_replace(holder, obj) \ 886 __ao2_global_obj_replace(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) 906 #define ao2_t_global_obj_replace_unref(holder, obj, tag) \ 907 __ao2_global_obj_replace_unref(&holder, (obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) 908 #define ao2_global_obj_replace_unref(holder, obj) \ 909 __ao2_global_obj_replace_unref(&holder, (obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) 923 #define ao2_t_global_obj_ref(holder, tag) \ 924 __ao2_global_obj_ref(&holder, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) 925 #define ao2_global_obj_ref(holder) \ 926 __ao2_global_obj_ref(&holder, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__, #holder) 1154 #define OBJ_POINTER OBJ_SEARCH_OBJECT 1155 #define OBJ_KEY OBJ_SEARCH_KEY 1156 #define OBJ_PARTIAL_KEY OBJ_SEARCH_PARTIAL_KEY 1280 typedef int (
ao2_sort_fn)(
const void *obj_left,
const void *obj_right,
int flags);
1308 #define ao2_t_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn, tag) \ 1309 __ao2_container_alloc_hash((ao2_options), (container_options), (n_buckets), (hash_fn), (sort_fn), (cmp_fn), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1310 #define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn) \ 1311 __ao2_container_alloc_hash((ao2_options), (container_options), (n_buckets), (hash_fn), (sort_fn), (cmp_fn), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1314 unsigned int container_options,
unsigned int n_buckets,
ao2_hash_fn *hash_fn,
1333 #define ao2_t_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn, tag) \ 1334 __ao2_container_alloc_list((ao2_options), (container_options), (sort_fn), (cmp_fn), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1335 #define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn) \ 1336 __ao2_container_alloc_list((ao2_options), (container_options), (sort_fn), (cmp_fn), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1356 #define ao2_t_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn, tag) \ 1357 __ao2_container_alloc_rbtree((ao2_options), (container_options), (sort_fn), (cmp_fn), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1358 #define ao2_container_alloc_rbtree(ao2_options, container_options, sort_fn, cmp_fn) \ 1359 __ao2_container_alloc_rbtree((ao2_options), (container_options), (sort_fn), (cmp_fn), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1428 #define ao2_t_container_clone(orig, flags, tag) \ 1429 __ao2_container_clone(orig, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1430 #define ao2_container_clone(orig, flags) \ 1431 __ao2_container_clone(orig, flags, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1442 typedef void (
ao2_prnt_fn)(
void *where,
const char *fmt, ...) __attribute__((
format(printf, 2, 3)));
1547 #define ao2_t_link(container, obj, tag) \ 1548 __ao2_link((container), (obj), 0, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1549 #define ao2_link(container, obj) \ 1550 __ao2_link((container), (obj), 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1570 #define ao2_t_link_flags(container, obj, flags, tag) \ 1571 __ao2_link((container), (obj), (flags), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1572 #define ao2_link_flags(container, obj, flags) \ 1573 __ao2_link((container), (obj), (flags), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1576 const char *tag,
const char *
file,
int line,
const char *func);
1596 #define ao2_t_unlink(container, obj, tag) \ 1597 __ao2_unlink((container), (obj), 0, (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1598 #define ao2_unlink(container, obj) \ 1599 __ao2_unlink((container), (obj), 0, NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1620 #define ao2_t_unlink_flags(container, obj, flags, tag) \ 1621 __ao2_unlink((container), (obj), (flags), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1622 #define ao2_unlink_flags(container, obj, flags) \ 1623 __ao2_unlink((container), (obj), (flags), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1626 const char *tag,
const char *
file,
int line,
const char *func);
1714 #define ao2_t_callback(c, flags, cb_fn, arg, tag) \ 1715 __ao2_callback((c), (flags), (cb_fn), (arg), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1716 #define ao2_callback(c, flags, cb_fn, arg) \ 1717 __ao2_callback((c), (flags), (cb_fn), (arg), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1741 #define ao2_t_callback_data(container, flags, cb_fn, arg, data, tag) \ 1742 __ao2_callback_data((container), (flags), (cb_fn), (arg), (data), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1743 #define ao2_callback_data(container, flags, cb_fn, arg, data) \ 1744 __ao2_callback_data((container), (flags), (cb_fn), (arg), (data), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1748 int line,
const char *func);
1754 #define ao2_t_find(container, arg, flags, tag) \ 1755 __ao2_find((container), (arg), (flags), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1756 #define ao2_find(container, arg, flags) \ 1757 __ao2_find((container), (arg), (flags), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1760 const char *tag,
const char *
file,
int line,
const char *func);
1768 #define ao2_weakproxy_find(c, arg, flags, tag) \ 1769 __ao2_weakproxy_find(c, arg, flags, tag, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1771 const char *tag,
const char *
file,
int line,
const char *func);
1925 #if defined(TEST_FRAMEWORK) 1931 #define ao2_t_iterator_next(iter, tag) \ 1932 __ao2_iterator_next((iter), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1933 #define ao2_iterator_next(iter) \ 1934 __ao2_iterator_next((iter), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1958 #define ao2_cleanup(obj) __ao2_cleanup_debug((obj), NULL, __FILE__, __LINE__, __PRETTY_FUNCTION__) 1959 #define ao2_t_cleanup(obj, tag) __ao2_cleanup_debug((obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__) 1981 #define AO2_FIELD_HASH_FN(stype, field, hash_fn) \ 1982 static int stype ## _hash_fn(const void *obj, const int flags) \ 1984 const struct stype *object = obj; \ 1986 switch (flags & OBJ_SEARCH_MASK) { \ 1987 case OBJ_SEARCH_KEY: \ 1990 case OBJ_SEARCH_OBJECT: \ 1991 key = object->field; \ 1997 return hash_fn(key); \ 2001 #define AO2_FIELD_TRANSFORM_CMP_FN(cmp) ((cmp) ? 0 : CMP_MATCH) 2002 #define AO2_FIELD_TRANSFORM_SORT_FN(cmp) (cmp) 2022 #define AO2_FIELD_CMP_FN(stype, fn_suffix, field, key_cmp, partial_key_cmp, transform, argconst) \ 2023 static int stype ## fn_suffix(argconst void *obj, argconst void *arg, int flags) \ 2025 const struct stype *object_left = obj, *object_right = arg; \ 2026 const char *right_key = arg; \ 2028 switch (flags & OBJ_SEARCH_MASK) { \ 2029 case OBJ_SEARCH_OBJECT: \ 2030 right_key = object_right->field; \ 2031 case OBJ_SEARCH_KEY: \ 2032 cmp = key_cmp(object_left->field, right_key); \ 2034 case OBJ_SEARCH_PARTIAL_KEY: \ 2035 cmp = partial_key_cmp(object_left->field, right_key, strlen(right_key)); \ 2041 return transform(cmp); \ 2055 #define AO2_STRING_FIELD_HASH_FN(stype, field) \ 2056 AO2_FIELD_HASH_FN(stype, field, ast_str_hash) 2057 #define AO2_STRING_FIELD_CASE_HASH_FN(stype, field) \ 2058 AO2_FIELD_HASH_FN(stype, field, ast_str_case_hash) 2071 #define AO2_STRING_FIELD_CMP_FN(stype, field) \ 2072 AO2_FIELD_CMP_FN(stype, _cmp_fn, field, strcmp, strncmp, AO2_FIELD_TRANSFORM_CMP_FN,) 2073 #define AO2_STRING_FIELD_CASE_CMP_FN(stype, field) \ 2074 AO2_FIELD_CMP_FN(stype, _cmp_fn, field, strcasecmp, strncasecmp, AO2_FIELD_TRANSFORM_CMP_FN,) 2087 #define AO2_STRING_FIELD_SORT_FN(stype, field) \ 2088 AO2_FIELD_CMP_FN(stype, _sort_fn, field, strcmp, strncmp, AO2_FIELD_TRANSFORM_SORT_FN, const) 2089 #define AO2_STRING_FIELD_CASE_SORT_FN(stype, field) \ 2090 AO2_FIELD_CMP_FN(stype, _sort_fn, field, strcasecmp, strncasecmp, AO2_FIELD_TRANSFORM_SORT_FN, const) void * __ao2_weakproxy_alloc(size_t data_size, ao2_destructor_fn destructor_fn, const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result
Allocate an ao2_weakproxy object.
void ao2_container_dump(struct ao2_container *self, enum search_flags flags, const char *name, void *where, ao2_prnt_fn *prnt, ao2_prnt_obj_fn *prnt_obj)
Display contents of the specified container.
Asterisk locking-related definitions:
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
void(* ao2_weakproxy_notification_cb)(void *weakproxy, void *data)
ao2_lock_req
Which lock to request.
void __ao2_cleanup_debug(void *obj, const char *tag, const char *file, int line, const char *function)
int ao2_weakproxy_unsubscribe(void *weakproxy, ao2_weakproxy_notification_cb cb, void *data, int flags)
Remove notification of real object destruction.
void * __ao2_find(struct ao2_container *c, const void *arg, enum search_flags flags, const char *tag, const char *file, int line, const char *func)
The arg parameter is a search key, but is not an object.
int __ao2_lock(void *a, enum ao2_lock_req lock_how, const char *file, const char *func, int line, const char *var)
Lock an object.
Allow objects with duplicate keys in container.
void ao2_iterator_cleanup(struct ao2_iterator *iter)
void __ao2_cleanup(void *obj)
int ao2_container_dup_weakproxy_objs(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags)
Copy object references associated with src container weakproxies into the dest container.
void * __ao2_global_obj_replace(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name) attribute_warn_unused_result
int ao2_ref_and_lock(void *obj)
Increment reference count on an object and lock it.
void ao2_iterator_restart(struct ao2_iterator *iter)
Restart an iteration.
void * __ao2_alloc(size_t data_size, ao2_destructor_fn destructor_fn, unsigned int options, const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result
int() ao2_sort_fn(const void *obj_left, const void *obj_right, int flags)
Type of generic container sort function.
int __ao2_unlock(void *a, const char *file, const char *func, int line, const char *var)
Unlock an object.
Assume that the ao2_container is already locked.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
void * __ao2_callback(struct ao2_container *c, enum search_flags flags, ao2_callback_fn *cb_fn, void *arg, const char *tag, const char *file, int line, const char *func)
int ao2_weakproxy_subscribe(void *weakproxy, ao2_weakproxy_notification_cb cb, void *data, int flags)
Request notification when weakproxy points to NULL.
search_flags
Flags passed to ao2_callback_fn(), ao2_hash_fn(), and ao2_sort_fn() to modify behaviour.
void * __ao2_get_weakproxy(void *obj, const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result
Get the weakproxy attached to obj.
void ao2_container_stats(struct ao2_container *self, enum search_flags flags, const char *name, void *where, ao2_prnt_fn *prnt)
Display statistics of the specified container.
struct ao2_container * __ao2_container_clone(struct ao2_container *orig, enum search_flags flags, const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result
Create a clone/copy of the given container.
int() ao2_callback_data_fn(void *obj, void *arg, void *data, int flags)
Type of a generic callback function.
The arg parameter has no meaning to the astobj2 code.
Insert objects at the beginning of the container. (Otherwise it is the opposite; insert at the end...
void() ao2_prnt_fn(void *where, const char *fmt,...)
Print output.
void * __ao2_global_obj_ref(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name) attribute_warn_unused_result
void * ao2_object_get_lockaddr(void *obj)
Return the mutex lock address of an object.
Traverse in ascending order (First to last container object)
int ao2_container_check(struct ao2_container *self, enum search_flags flags)
Perform an integrity check on the specified container.
void ao2_container_unregister(const char *name)
Unregister a container for CLI stats and integrity check.
int __ao2_ref(void *o, int delta, const char *tag, const char *file, int line, const char *func)
int ao2_container_register(const char *name, struct ao2_container *self, ao2_prnt_obj_fn *prnt_obj)
Register a container for CLI stats and integrity check.
int() ao2_callback_fn(void *obj, void *arg, int flags)
Type of a generic callback function.
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
int __ao2_weakproxy_ref_object(void *weakproxy, int delta, int flags, const char *tag, const char *file, int line, const char *func)
Run ao2_t_ref on the object associated with weakproxy.
The ao2 container objects with duplicate keys option field mask.
Inlinable API function macro.
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) attribute_warn_unused_result
#define ao2_ref(o, delta)
void * __ao2_weakproxy_get_object(void *weakproxy, int flags, const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result
Get the object associated with weakproxy.
A set of macros to manage forward-linked lists.
void * __ao2_weakproxy_find(struct ao2_container *c, const void *arg, enum search_flags flags, const char *tag, const char *file, int line, const char *func)
AST_LIST_HEAD_NOLOCK(contactliststruct, contact)
Traverse in descending order (Last to first container object)
struct ao2_weakproxy::@224 destroyed_cb
int __ao2_global_obj_replace_unref(struct ao2_global_obj *holder, void *obj, const char *tag, const char *file, int line, const char *func, const char *name)
int __ao2_weakproxy_set_object(void *weakproxy, void *obj, int flags, const char *tag, const char *file, int line, const char *func)
Associate weakproxy with obj.
ao2_alloc_opts
Options available when allocating an ao2 object.
int() ao2_hash_fn(const void *obj, int flags)
void * __ao2_callback_data(struct ao2_container *c, enum search_flags flags, ao2_callback_data_fn *cb_fn, void *arg, void *data, const char *tag, const char *file, int line, const char *func)
int ao2_container_dup(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags)
Copy all object references in the src container into the dest container.
void * __ao2_alloc_with_lockobj(size_t data_size, ao2_destructor_fn destructor_fn, void *lockobj, const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result
int __ao2_trylock(void *a, enum ao2_lock_req lock_how, const char *file, const char *func, int line, const char *var)
Try locking– (don't block if fail)
void(* ao2_destructor_fn)(void *vdoomed)
Typedef for an object destructor.
Traverse in pre-order (Node then children, for tree container)
_cb_results
A callback function will return a combination of CMP_MATCH and CMP_STOP. The latter will terminate th...
General Definitions for Asterisk top level program Included by asterisk.h to handle platform-specific...
int ao2_match_by_addr(void *obj, void *arg, int flags)
A common ao2_callback is one that matches by address.
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) attribute_warn_unused_result
#define attribute_warn_unused_result
void * __ao2_iterator_next(struct ao2_iterator *iter, const char *tag, const char *file, int line, const char *func) attribute_warn_unused_result
int ao2_unlock_and_unref(void *obj)
Unlock an object and decrement its reference count.
Assume that the ao2_container is already locked.
The arg parameter is an object of the same type.
Replace objects with duplicate keys in container.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Structure for rwlock and tracking information.
Traverse in post-order (Children then node, for tree container)
unsigned int ao2_options_get(void *obj)
Retrieve the ao2 options used to create the object.
This struct should be opaque, but it's size is needed.
int __ao2_link(struct ao2_container *c, void *obj_new, int flags, const char *tag, const char *file, int line, const char *func)
Reject objects with duplicate keys in container.
int ao2_iterator_count(struct ao2_iterator *iter)
Get a count of the iterated container objects.
Search option field mask.
void() ao2_prnt_obj_fn(void *v_obj, void *where, ao2_prnt_fn *prnt)
Print object key.
ao2_container_opts
Options available when allocating an ao2 container object.
static snd_pcm_format_t format
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
Reject duplicate objects in container.
Traverse order option field mask.
void * __ao2_unlink(struct ao2_container *c, void *obj, int flags, const char *tag, const char *file, int line, const char *func)
#define AST_INLINE_API(hdr, body)
struct ao2_container * __ao2_container_alloc_rbtree(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) attribute_warn_unused_result