summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2014-07-11 23:00:21 +0000
committerMatthew Jordan <mjordan@digium.com>2014-07-11 23:00:21 +0000
commit0d1288e2d2abb96ba457e2ae14cbf44280a708cf (patch)
tree5e5c22adcdc88ab589b508f773ed7bd34599e657 /include
parent694b68e54466c1c2c6a32acbe5cb74db0dad8e80 (diff)
astobj2: Add tag variants for ao2_bump, ao2_cleanup, and ao2_replace
Tags are useful in hunting down ref imbalances; this patch adds tag variants for these commonly used macros/functions. Review: https://reviewboard.asterisk.org/r/3750/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@418419 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/astobj2.h20
1 files changed, 13 insertions, 7 deletions
diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h
index 12b1b639b..83af495e1 100644
--- a/include/asterisk/astobj2.h
+++ b/include/asterisk/astobj2.h
@@ -538,14 +538,16 @@ unsigned int ao2_options_get(void *obj);
* \param obj AO2 object to bump the refcount on.
* \retval The given \a obj pointer.
*/
-#define ao2_bump(obj) \
+#define ao2_t_bump(obj, tag) \
({ \
typeof(obj) __obj_ ## __LINE__ = (obj); \
if (__obj_ ## __LINE__) { \
- ao2_ref(__obj_ ## __LINE__, +1); \
+ ao2_t_ref(__obj_ ## __LINE__, +1, (tag)); \
} \
__obj_ ## __LINE__; \
})
+#define ao2_bump(obj) \
+ ao2_t_bump((obj), "")
int __ao2_ref_debug(void *o, int delta, const char *tag, const char *file, int line, const char *func);
int __ao2_ref(void *o, int delta);
@@ -557,20 +559,22 @@ int __ao2_ref(void *o, int delta);
* \param dst Pointer to the object that will be cleaned up.
* \param src Pointer to the object replacing it.
*/
-#define ao2_replace(dst, src) \
+#define ao2_t_replace(dst, src, tag) \
{\
typeof(dst) *__dst_ ## __LINE__ = &dst; \
typeof(src) __src_ ## __LINE__ = src; \
if (__src_ ## __LINE__ != *__dst_ ## __LINE__) { \
if (__src_ ## __LINE__) {\
- ao2_ref(__src_ ## __LINE__, +1); \
+ ao2_t_ref(__src_ ## __LINE__, +1, (tag)); \
} \
if (*__dst_ ## __LINE__) {\
- ao2_ref(*__dst_ ## __LINE__, -1); \
+ ao2_t_ref(*__dst_ ## __LINE__, -1, (tag)); \
} \
*__dst_ ## __LINE__ = __src_ ## __LINE__; \
} \
}
+#define ao2_replace(dst, src) \
+ ao2_t_replace((dst), (src), "")
/*! @} */
@@ -1965,11 +1969,13 @@ void ao2_bt(void); /* backtrace */
* allocation/find functions can fail and we don't want to try to tear
* down a NULL */
void __ao2_cleanup(void *obj);
-void __ao2_cleanup_debug(void *obj, const char *file, int line, const char *function);
+void __ao2_cleanup_debug(void *obj, const char *tag, const char *file, int line, const char *function);
#ifdef REF_DEBUG
-#define ao2_cleanup(obj) __ao2_cleanup_debug((obj), __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_cleanup(obj) __ao2_cleanup_debug((obj), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_t_cleanup(obj, tag) __ao2_t_cleanup_debug((obj), (tag), __FILE__, __LINE__, __PRETTY_FUNCTION__)
#else
#define ao2_cleanup(obj) __ao2_cleanup(obj)
+#define ao2_t_cleanup(obj, tag) __ao2_cleanup((obj))
#endif
void ao2_iterator_cleanup(struct ao2_iterator *iter);