[svn-commits] mjordan: trunk r418419 - in /trunk: include/asterisk/astobj2.h main/astobj2.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Jul 11 18:00:28 CDT 2014


Author: mjordan
Date: Fri Jul 11 18:00:21 2014
New Revision: 418419

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418419
Log:
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/

Modified:
    trunk/include/asterisk/astobj2.h
    trunk/main/astobj2.c

Modified: trunk/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/astobj2.h?view=diff&rev=418419&r1=418418&r2=418419
==============================================================================
--- trunk/include/asterisk/astobj2.h (original)
+++ trunk/include/asterisk/astobj2.h Fri Jul 11 18:00:21 2014
@@ -538,14 +538,16 @@
  * \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 @@
  * \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 @@
  * 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);
 

Modified: trunk/main/astobj2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/astobj2.c?view=diff&rev=418419&r1=418418&r2=418419
==============================================================================
--- trunk/main/astobj2.c (original)
+++ trunk/main/astobj2.c Fri Jul 11 18:00:21 2014
@@ -524,10 +524,10 @@
 	return internal_ao2_ref(user_data, delta, __FILE__, __LINE__, __FUNCTION__);
 }
 
-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)
 {
 	if (obj) {
-		__ao2_ref_debug(obj, -1, "ao2_cleanup", file, line, function);
+		__ao2_ref_debug(obj, -1, tag, file, line, function);
 	}
 }
 




More information about the svn-commits mailing list