[svn-commits] gtjoseph: branch 12 r416995 - in /branches/12: ./ include/asterisk/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Jun 22 13:44:27 CDT 2014


Author: gtjoseph
Date: Sun Jun 22 13:44:23 2014
New Revision: 416995

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416995
Log:
astobj2: Add an ao2_replace macro to astobj2.h

This macro replaces one object reference with another cleaning up the original.

param dst Pointer to the object that will be cleaned up.
param src Pointer to the object replacing it.

src's ref count is bumped if it's non-NULL.
dst's ref count is decremented if it's non-NULL.
src is assigned to dst,

This patch was reviewed on IRC by coreyfarrell and mjordan.
 
Tested by: George Joseph

Modified:
    branches/12/Makefile
    branches/12/Makefile.rules
    branches/12/include/asterisk/astobj2.h

Modified: branches/12/Makefile
URL: http://svnview.digium.com/svn/asterisk/branches/12/Makefile?view=diff&rev=416995&r1=416994&r2=416995
==============================================================================
--- branches/12/Makefile (original)
+++ branches/12/Makefile Sun Jun 22 13:44:23 2014
@@ -188,7 +188,6 @@
   _ASTCFLAGS+=-Werror
   _ASTCFLAGS+=-Wunused
   _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
-  _ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
   _ASTCFLAGS+=$(AST_TRAMPOLINES)
   _ASTCFLAGS+=-Wundef
   _ASTCFLAGS+=-Wmissing-format-attribute

Modified: branches/12/Makefile.rules
URL: http://svnview.digium.com/svn/asterisk/branches/12/Makefile.rules?view=diff&rev=416995&r1=416994&r2=416995
==============================================================================
--- branches/12/Makefile.rules (original)
+++ branches/12/Makefile.rules Sun Jun 22 13:44:23 2014
@@ -82,6 +82,8 @@
 # and if that doesn't fail then compile again with optimizer disabled
 ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS))$(AST_DEVMODE),DONT_OPTIMIZEyes)
 COMPILE_DOUBLE=yes
+else
+_ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
 endif
 
 ifeq ($(findstring BUILD_NATIVE,$(MENUSELECT_CFLAGS)),BUILD_NATIVE)

Modified: branches/12/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/branches/12/include/asterisk/astobj2.h?view=diff&rev=416995&r1=416994&r2=416995
==============================================================================
--- branches/12/include/asterisk/astobj2.h (original)
+++ branches/12/include/asterisk/astobj2.h Sun Jun 22 13:44:23 2014
@@ -549,6 +549,26 @@
 
 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);
+
+/*!
+ * \since 12.4.0
+ * \brief Replace one object reference with another cleaning up the original.
+ *
+ * \param dst Pointer to the object that will be cleaned up.
+ * \param src Pointer to the object replacing it.
+ */
+#define ao2_replace(dst, src) \
+	{\
+		typeof(dst) *__dst_ ## __LINE__ = &dst; \
+		typeof(src) __src_ ## __LINE__ = src; \
+		if (__src_ ## __LINE__) {\
+			ao2_ref(__src_ ## __LINE__, +1); \
+		} \
+		if (*__dst_ ## __LINE__) {\
+			ao2_ref(*__dst_ ## __LINE__, -1); \
+		} \
+		*__dst_ ## __LINE__ = __src_ ## __LINE__; \
+	}
 
 /*! @} */
 




More information about the svn-commits mailing list