From: Corey Farrell Date: Fri, 11 Jul 2014 21:09:43 +0000 (+0000) Subject: astobj2: tweak ao2_replace to do nothing when it would be a NoOp X-Git-Tag: 12.5.0-rc1~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=565d8eb17cccc9544cbb806323199dc6a202a441;p=thirdparty%2Fasterisk.git 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/ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@418396 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h index d1c75ff5f0..12b1b639b7 100644 --- a/include/asterisk/astobj2.h +++ b/include/asterisk/astobj2.h @@ -561,13 +561,15 @@ int __ao2_ref(void *o, int delta); {\ 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__; \ } /*! @} */