17 #ifndef _ASTERISK_ASTOBJ2_H
18 #define _ASTERISK_ASTOBJ2_H
417 #if defined(REF_DEBUG)
419 #define ao2_t_alloc(data_size, destructor_fn, debug_msg) __ao2_alloc_debug((data_size), (destructor_fn), (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__, 1)
420 #define ao2_alloc(data_size, destructor_fn) __ao2_alloc_debug((data_size), (destructor_fn), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 1)
422 #elif defined(__AST_DEBUG_MALLOC)
424 #define ao2_t_alloc(data_size, destructor_fn, debug_msg) __ao2_alloc_debug((data_size), (destructor_fn), (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__, 0)
425 #define ao2_alloc(data_size, destructor_fn) __ao2_alloc_debug((data_size), (destructor_fn), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 0)
429 #define ao2_t_alloc(data_size, destructor_fn, debug_msg) __ao2_alloc((data_size), (destructor_fn))
430 #define ao2_alloc(data_size, destructor_fn) __ao2_alloc((data_size), (destructor_fn))
435 const char *file,
int line,
const char *funcname,
int ref_debug);
466 #define ao2_t_ref(o,delta,tag) __ao2_ref_debug((o), (delta), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
467 #define ao2_ref(o,delta) __ao2_ref_debug((o), (delta), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
471 #define ao2_t_ref(o,delta,tag) __ao2_ref((o), (delta))
472 #define ao2_ref(o,delta) __ao2_ref((o), (delta))
476 int __ao2_ref_debug(
void *o,
int delta,
const char *tag,
const char *file,
int line,
const char *funcname);
487 int __ao2_lock(
void *a,
const char *file,
const char *func,
int line,
const char *
var);
488 #define ao2_lock(a) __ao2_lock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
496 int __ao2_unlock(
void *a,
const char *file,
const char *func,
int line,
const char *
var);
497 #define ao2_unlock(a) __ao2_unlock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
505 int __ao2_trylock(
void *a,
const char *file,
const char *func,
int line,
const char *
var);
506 #define ao2_trylock(a) __ao2_trylock(a, __FILE__, __PRETTY_FUNCTION__, __LINE__, #a)
721 #if defined(REF_DEBUG)
723 #define ao2_t_container_alloc(arg1,arg2,arg3,arg4) __ao2_container_alloc_debug((arg1), (arg2), (arg3), (arg4), __FILE__, __LINE__, __PRETTY_FUNCTION__, 1)
724 #define ao2_container_alloc(arg1,arg2,arg3) __ao2_container_alloc_debug((arg1), (arg2), (arg3), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 1)
726 #elif defined(__AST_DEBUG_MALLOC)
728 #define ao2_t_container_alloc(arg1,arg2,arg3,arg4) __ao2_container_alloc_debug((arg1), (arg2), (arg3), (arg4), __FILE__, __LINE__, __PRETTY_FUNCTION__, 0)
729 #define ao2_container_alloc(arg1,arg2,arg3) __ao2_container_alloc_debug((arg1), (arg2), (arg3), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 0)
733 #define ao2_t_container_alloc(arg1,arg2,arg3,arg4) __ao2_container_alloc((arg1), (arg2), (arg3))
734 #define ao2_container_alloc(arg1,arg2,arg3) __ao2_container_alloc((arg1), (arg2), (arg3))
742 char *tag,
char *file,
int line,
const char *funcname,
779 #define ao2_t_link(arg1, arg2, arg3) __ao2_link_debug((arg1), (arg2), (arg3), __FILE__, __LINE__, __PRETTY_FUNCTION__)
780 #define ao2_link(arg1, arg2) __ao2_link_debug((arg1), (arg2), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
784 #define ao2_t_link(arg1, arg2, arg3) __ao2_link((arg1), (arg2))
785 #define ao2_link(arg1, arg2) __ao2_link((arg1), (arg2))
811 #define ao2_t_unlink(arg1, arg2, arg3) __ao2_unlink_debug((arg1), (arg2), (arg3), __FILE__, __LINE__, __PRETTY_FUNCTION__)
812 #define ao2_unlink(arg1, arg2) __ao2_unlink_debug((arg1), (arg2), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
816 #define ao2_t_unlink(arg1, arg2, arg3) __ao2_unlink((arg1), (arg2))
817 #define ao2_unlink(arg1, arg2) __ao2_unlink((arg1), (arg2))
904 #define ao2_t_callback(c,flags,cb_fn,arg,tag) __ao2_callback_debug((c), (flags), (cb_fn), (arg), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
905 #define ao2_callback(c,flags,cb_fn,arg) __ao2_callback_debug((c), (flags), (cb_fn), (arg), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
909 #define ao2_t_callback(c,flags,cb_fn,arg,tag) __ao2_callback((c), (flags), (cb_fn), (arg))
910 #define ao2_callback(c,flags,cb_fn,arg) __ao2_callback((c), (flags), (cb_fn), (arg))
915 void *arg,
char *tag,
char *file,
int line,
const char *funcname);
937 #define ao2_t_callback_data(arg1,arg2,arg3,arg4,arg5,arg6) __ao2_callback_data_debug((arg1), (arg2), (arg3), (arg4), (arg5), (arg6), __FILE__, __LINE__, __PRETTY_FUNCTION__)
938 #define ao2_callback_data(arg1,arg2,arg3,arg4,arg5) __ao2_callback_data_debug((arg1), (arg2), (arg3), (arg4), (arg5), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
942 #define ao2_t_callback_data(arg1,arg2,arg3,arg4,arg5,arg6) __ao2_callback_data((arg1), (arg2), (arg3), (arg4), (arg5))
943 #define ao2_callback_data(arg1,arg2,arg3,arg4,arg5) __ao2_callback_data((arg1), (arg2), (arg3), (arg4), (arg5))
949 char *file,
int line,
const char *funcname);
958 #define ao2_t_find(arg1,arg2,arg3,arg4) __ao2_find_debug((arg1), (arg2), (arg3), (arg4), __FILE__, __LINE__, __PRETTY_FUNCTION__)
959 #define ao2_find(arg1,arg2,arg3) __ao2_find_debug((arg1), (arg2), (arg3), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
963 #define ao2_t_find(arg1,arg2,arg3,arg4) __ao2_find((arg1), (arg2), (arg3))
964 #define ao2_find(arg1,arg2,arg3) __ao2_find((arg1), (arg2), (arg3))
969 char *file,
int line,
const char *funcname);
1120 #define ao2_t_iterator_next(arg1, arg2) __ao2_iterator_next_debug((arg1), (arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
1121 #define ao2_iterator_next(arg1) __ao2_iterator_next_debug((arg1), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
1125 #define ao2_t_iterator_next(arg1, arg2) __ao2_iterator_next((arg1))
1126 #define ao2_iterator_next(arg1) __ao2_iterator_next((arg1))
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
void * __ao2_callback_data(struct ao2_container *c, enum search_flags flags, ao2_callback_data_fn *cb_fn, void *arg, void *data)
void * __ao2_find(struct ao2_container *c, void *arg, enum search_flags flags)
int __ao2_unlock(void *a, const char *file, const char *func, int line, const char *var)
Unlock an object.
Continue if a match is not found in the hashed out bucket.
void * __ao2_callback(struct ao2_container *c, enum search_flags flags, ao2_callback_fn *cb_fn, void *arg)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags)
Create an iterator for a container.
search_flags
Flags passed to ao2_callback() and ao2_hash_fn() to modify its behaviour.
void * __ao2_link_debug(struct ao2_container *c, void *new_obj, char *tag, char *file, int line, const char *funcname)
int __ao2_trylock(void *a, const char *file, const char *func, int line, const char *var)
Try locking– (don't block if fail)
void * ao2_object_get_lockaddr(void *obj)
Return the lock address of an object.
void * __ao2_alloc_debug(const size_t data_size, ao2_destructor_fn destructor_fn, char *tag, const char *file, int line, const char *funcname, int ref_debug)
int __ao2_ref(void *o, int delta)
A set of macros to manage forward-linked lists.
void(* ao2_destructor_fn)(void *)
Typedef for an object destructor. This is called just before freeing the memory for the object...
int __ao2_lock(void *a, const char *file, const char *func, int line, const char *var)
Lock an object.
_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...
struct ao2_container * __ao2_container_alloc(const unsigned int n_buckets, ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn)
void ao2_iterator_destroy(struct ao2_iterator *i)
Destroy a container iterator.
void * __ao2_callback_debug(struct ao2_container *c, enum search_flags flags, ao2_callback_fn *cb_fn, void *arg, char *tag, char *file, int line, const char *funcname)
ao2_callback_fn ao2_match_by_addr
a very common callback is one that matches by address.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
struct ao2_container * __ao2_container_alloc_debug(const unsigned int n_buckets, ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn, char *tag, char *file, int line, const char *funcname, int ref_debug)
int( ao2_hash_fn)(const void *obj, const int flags)
void * __ao2_unlink(struct ao2_container *c, void *obj)
void * __ao2_find_debug(struct ao2_container *c, void *arg, enum search_flags flags, char *tag, char *file, int line, const char *funcname)
int __ao2_ref_debug(void *o, int delta, const char *tag, const char *file, int line, const char *funcname)
void * __ao2_callback_data_debug(struct ao2_container *c, enum search_flags flags, ao2_callback_data_fn *cb_fn, void *arg, void *data, char *tag, char *file, int line, const char *funcname)
void * __ao2_unlink_debug(struct ao2_container *c, void *obj, char *tag, char *file, int line, const char *funcname)
void * __ao2_alloc(const size_t data_size, ao2_destructor_fn destructor_fn)
void * __ao2_iterator_next_debug(struct ao2_iterator *a, char *tag, char *file, int line, const char *funcname)
void * __ao2_link(struct ao2_container *c, void *newobj)
ao2_hash_fn * hash_fn
Event type specific hash function.
void * __ao2_iterator_next(struct ao2_iterator *a)
int( ao2_callback_data_fn)(void *obj, void *arg, void *data, int flags)
Type of a generic callback function.
int( ao2_callback_fn)(void *obj, void *arg, int flags)
Type of a generic callback function.