aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-05-04 19:34:33 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-05-04 19:34:33 +0000
commitb6d7672de3a8456657d7252a5db3ec19069d81c0 (patch)
treedc4c58170a0985b558c769b9523942f98092fe7d /include
parent86849e1951c5359980955ed796e7e7d6402f4590 (diff)
Merged revisions 192059 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r192059 | kpfleming | 2009-05-04 18:24:16 +0200 (Mon, 04 May 2009) | 5 lines Ensure that astobj2 memory allocations are properly accounted for when MALLOC_DEBUG is used This commit ensures that all astobj2 allocated objects are properly accounted for in MALLOC_DEBUG mode by passing down the file/function/line information from the module/function that actually called the astobj2 allocation function. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@192175 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/astobj2.h54
1 files changed, 47 insertions, 7 deletions
diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h
index ee82e5d9b..4b14615ec 100644
--- a/include/asterisk/astobj2.h
+++ b/include/asterisk/astobj2.h
@@ -402,8 +402,7 @@ typedef void (*ao2_destructor_fn)(void *);
* @{
*/
-#ifdef REF_DEBUG
-
+#if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC)
#define ao2_t_alloc(data_size, destructor_fn, debug_msg) _ao2_alloc_debug((data_size), (destructor_fn), (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_alloc(data_size, destructor_fn) _ao2_alloc_debug((data_size), (destructor_fn), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
@@ -414,6 +413,7 @@ typedef void (*ao2_destructor_fn)(void *);
#define ao2_alloc(data_size, destructor_fn) _ao2_alloc((data_size), (destructor_fn))
#endif
+
void *_ao2_alloc_debug(const size_t data_size, ao2_destructor_fn destructor_fn, char *tag, char *file, int line, const char *funcname);
void *_ao2_alloc(const size_t data_size, ao2_destructor_fn destructor_fn);
/*! @} */
@@ -442,16 +442,23 @@ void *_ao2_alloc(const size_t data_size, ao2_destructor_fn destructor_fn);
*/
#ifdef REF_DEBUG
+
#define ao2_t_ref(o,delta,tag) _ao2_ref_debug((o), (delta), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_ref(o,delta) _ao2_ref_debug((o), (delta), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#else
+
#define ao2_t_ref(o,delta,tag) _ao2_ref((o), (delta))
#define ao2_ref(o,delta) _ao2_ref((o), (delta))
+
#endif
+
int _ao2_ref_debug(void *o, int delta, char *tag, char *file, int line, const char *funcname);
int _ao2_ref(void *o, int delta);
/*! @} */
+/*! @} */
+
/*! \brief
* Lock an object.
*
@@ -691,23 +698,29 @@ struct ao2_container;
* destructor is set implicitly.
*/
-#ifdef REF_DEBUG
+#if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC)
+
#define ao2_t_container_alloc(arg1,arg2,arg3,arg4) _ao2_container_alloc_debug((arg1), (arg2), (arg3), (arg4), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_container_alloc(arg1,arg2,arg3) _ao2_container_alloc_debug((arg1), (arg2), (arg3), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#else
+
#define ao2_t_container_alloc(arg1,arg2,arg3,arg4) _ao2_container_alloc((arg1), (arg2), (arg3))
#define ao2_container_alloc(arg1,arg2,arg3) _ao2_container_alloc((arg1), (arg2), (arg3))
+
#endif
+
struct ao2_container *_ao2_container_alloc(const unsigned int n_buckets,
- ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn);
+ ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn);
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);
+ ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn,
+ char *tag, char *file, int line, const char *funcname);
/*! \brief
* Returns the number of elements in a container.
*/
int ao2_container_count(struct ao2_container *c);
+
/*@} */
/*! \name Object Management
@@ -738,15 +751,19 @@ int ao2_container_count(struct ao2_container *c);
#define ao2_t_link(arg1, arg2, arg3) _ao2_link_debug((arg1), (arg2), (arg3), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_link(arg1, arg2) _ao2_link_debug((arg1), (arg2), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#else
+
#define ao2_t_link(arg1, arg2, arg3) _ao2_link((arg1), (arg2))
#define ao2_link(arg1, arg2) _ao2_link((arg1), (arg2))
+
#endif
+
void *_ao2_link_debug(struct ao2_container *c, void *new_obj, char *tag, char *file, int line, const char *funcname);
void *_ao2_link(struct ao2_container *c, void *newobj);
/*!
- * \brief Remove an object from the container
+ * \brief Remove an object from a container
*
* \param c the container
* \param obj the object to unlink
@@ -762,12 +779,17 @@ void *_ao2_link(struct ao2_container *c, void *newobj);
* refcount will be decremented).
*/
#ifdef REF_DEBUG
+
#define ao2_t_unlink(arg1, arg2, arg3) _ao2_unlink_debug((arg1), (arg2), (arg3), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_unlink(arg1, arg2) _ao2_unlink_debug((arg1), (arg2), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#else
+
#define ao2_t_unlink(arg1, arg2, arg3) _ao2_unlink((arg1), (arg2))
#define ao2_unlink(arg1, arg2) _ao2_unlink((arg1), (arg2))
+
#endif
+
void *_ao2_unlink_debug(struct ao2_container *c, void *obj, char *tag, char *file, int line, const char *funcname);
void *_ao2_unlink(struct ao2_container *c, void *obj);
@@ -777,6 +799,7 @@ struct ao2_list {
struct ao2_list *next;
void *obj; /* pointer to the user portion of the object */
};
+
/*@} */
/*! \brief
@@ -859,12 +882,17 @@ struct ao2_list {
* @{
*/
#ifdef REF_DEBUG
+
#define ao2_t_callback(c,flags,cb_fn,arg,tag) _ao2_callback_debug((c), (flags), (cb_fn), (arg), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_callback(c,flags,cb_fn,arg) _ao2_callback_debug((c), (flags), (cb_fn), (arg), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#else
+
#define ao2_t_callback(c,flags,cb_fn,arg,tag) _ao2_callback((c), (flags), (cb_fn), (arg))
#define ao2_callback(c,flags,cb_fn,arg) _ao2_callback((c), (flags), (cb_fn), (arg))
+
#endif
+
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);
@@ -906,12 +934,17 @@ void *_ao2_callback_data(struct ao2_container *c,
* XXX possibly change order of arguments ?
*/
#ifdef REF_DEBUG
+
#define ao2_t_find(arg1,arg2,arg3,arg4) _ao2_find_debug((arg1), (arg2), (arg3), (arg4), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_find(arg1,arg2,arg3) _ao2_find_debug((arg1), (arg2), (arg3), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#else
+
#define ao2_t_find(arg1,arg2,arg3,arg4) _ao2_find((arg1), (arg2), (arg3))
#define ao2_find(arg1,arg2,arg3) _ao2_find((arg1), (arg2), (arg3))
+
#endif
+
void *_ao2_find_debug(struct ao2_container *c, void *arg, enum search_flags flags, char *tag, char *file, int line, const char *funcname);
void *_ao2_find(struct ao2_container *c, void *arg, enum search_flags flags);
@@ -1011,16 +1044,23 @@ struct ao2_iterator {
searches for the next pointer */
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags);
+
#ifdef REF_DEBUG
+
#define ao2_t_iterator_next(arg1, arg2) _ao2_iterator_next_debug((arg1), (arg2), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#define ao2_iterator_next(arg1) _ao2_iterator_next_debug((arg1), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#else
+
#define ao2_t_iterator_next(arg1, arg2) _ao2_iterator_next((arg1))
#define ao2_iterator_next(arg1) _ao2_iterator_next((arg1))
+
#endif
+
void *_ao2_iterator_next_debug(struct ao2_iterator *a, char *tag, char *file, int line, const char *funcname);
void *_ao2_iterator_next(struct ao2_iterator *a);
/* extra functions */
void ao2_bt(void); /* backtrace */
+
#endif /* _ASTERISK_ASTOBJ2_H */