[asterisk-commits] coreyfarrell: trunk r418397 - in /trunk: ./ include/asterisk/astobj2.h

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 11 16:10:51 CDT 2014


Author: coreyfarrell
Date: Fri Jul 11 16:10:45 2014
New Revision: 418397

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=418397
Log:
astobj2: tweak ao2_replace to do nothing when it would be a NoOp

This change causes ao2_replace to do nothing when src == dst. This
avoids REF_DEBUG logging when we're not actually doing anything.

Review: https://reviewboard.asterisk.org/r/3743/
........

Merged revisions 418396 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/astobj2.h

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/include/asterisk/astobj2.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/astobj2.h?view=diff&rev=418397&r1=418396&r2=418397
==============================================================================
--- trunk/include/asterisk/astobj2.h (original)
+++ trunk/include/asterisk/astobj2.h Fri Jul 11 16:10:45 2014
@@ -561,13 +561,15 @@
 	{\
 		typeof(dst) *__dst_ ## __LINE__ = &dst; \
 		typeof(src) __src_ ## __LINE__ = src; \
-		if (__src_ ## __LINE__) {\
-			ao2_ref(__src_ ## __LINE__, +1); \
+		if (__src_ ## __LINE__ != *__dst_ ## __LINE__) { \
+			if (__src_ ## __LINE__) {\
+				ao2_ref(__src_ ## __LINE__, +1); \
+			} \
+			if (*__dst_ ## __LINE__) {\
+				ao2_ref(*__dst_ ## __LINE__, -1); \
+			} \
+			*__dst_ ## __LINE__ = __src_ ## __LINE__; \
 		} \
-		if (*__dst_ ## __LINE__) {\
-			ao2_ref(*__dst_ ## __LINE__, -1); \
-		} \
-		*__dst_ ## __LINE__ = __src_ ## __LINE__; \
 	}
 
 /*! @} */




More information about the asterisk-commits mailing list