[asterisk-commits] dlee: branch dlee/ASTERISK-22243 r396551 - in /team/dlee/ASTERISK-22243: incl...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 12 14:16:25 CDT 2013


Author: dlee
Date: Mon Aug 12 14:16:23 2013
New Revision: 396551

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396551
Log:
Changed ao2_refbump to ao2_bump and made it NULL safe

Modified:
    team/dlee/ASTERISK-22243/include/asterisk/astobj2.h
    team/dlee/ASTERISK-22243/main/stasis.c

Modified: team/dlee/ASTERISK-22243/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22243/include/asterisk/astobj2.h?view=diff&rev=396551&r1=396550&r2=396551
==============================================================================
--- team/dlee/ASTERISK-22243/include/asterisk/astobj2.h (original)
+++ team/dlee/ASTERISK-22243/include/asterisk/astobj2.h Mon Aug 12 14:16:23 2013
@@ -515,16 +515,18 @@
  * \brief Bump refcount on an AO2 object by one, returning the object.
  *
  * This is useful for inlining a ref bump, and you don't care about the ref
- * count.
+ * count. Also \c NULL safe, for even more convenience.
  *
  * \param obj AO2 object to bump the refcount on.
  * \retval The given \a obj pointer.
  */
-#define ao2_refbump(obj)				\
-	({						\
-		typeof(obj) __obj_ ## __LINE__ = (obj);	\
-		ao2_ref(__obj_ ## __LINE__, +1);	\
-		__obj_ ## __LINE__;			\
+#define ao2_bump(obj)						\
+	({							\
+		typeof(obj) __obj_ ## __LINE__ = (obj);		\
+		if (__obj_ ## __LINE__) {			\
+			ao2_ref(__obj_ ## __LINE__, +1);	\
+		}						\
+		__obj_ ## __LINE__;				\
 	})
 
 int __ao2_ref_debug(void *o, int delta, const char *tag, const char *file, int line, const char *func);

Modified: team/dlee/ASTERISK-22243/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/ASTERISK-22243/main/stasis.c?view=diff&rev=396551&r1=396550&r2=396551
==============================================================================
--- team/dlee/ASTERISK-22243/main/stasis.c (original)
+++ team/dlee/ASTERISK-22243/main/stasis.c Mon Aug 12 14:16:23 2013
@@ -322,7 +322,7 @@
 		size_t i;
 		/* The subscription may be the last ref to this topic. Hold
 		 * the topic ref open until after the unlock. */
-		RAII_VAR(struct stasis_topic *, topic, ao2_refbump(sub->topic),
+		RAII_VAR(struct stasis_topic *, topic, ao2_bump(sub->topic),
 			ao2_cleanup);
 		SCOPED_AO2LOCK(lock_topic, topic);
 
@@ -520,7 +520,7 @@
 	size_t i;
 	/* The topic may be unref'ed by the subscription invocation.
 	 * Make sure we hold onto a reference while dispatching. */
-	RAII_VAR(struct stasis_topic *, topic, ao2_refbump(_topic),
+	RAII_VAR(struct stasis_topic *, topic, ao2_bump(_topic),
 		ao2_cleanup);
 	SCOPED_AO2LOCK(lock, topic);
 




More information about the asterisk-commits mailing list