[Asterisk-code-review] cdr.c: Replace inlined code with ao2 t replace() (asterisk[14])

Richard Mudgett asteriskteam at digium.com
Mon Oct 9 13:29:56 CDT 2017


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/6703


Change subject: cdr.c: Replace inlined code with ao2_t_replace()
......................................................................

cdr.c: Replace inlined code with ao2_t_replace()

Change-Id: I9f424f5282ca7d833592f958d95f1b2bafb549b0
---
M main/cdr.c
1 file changed, 2 insertions(+), 10 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/03/6703/1

diff --git a/main/cdr.c b/main/cdr.c
index 4bcfc05..6a5b33c 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -754,11 +754,7 @@
  */
 static void cdr_object_snapshot_copy(struct cdr_object_snapshot *dst, struct cdr_object_snapshot *src)
 {
-	if (dst->snapshot) {
-		ao2_t_ref(dst->snapshot, -1, "release old snapshot during copy");
-	}
-	dst->snapshot = src->snapshot;
-	ao2_t_ref(dst->snapshot, +1, "bump new snapshot during copy");
+	ao2_t_replace(dst->snapshot, src->snapshot, "CDR snapshot copy");
 	strcpy(dst->userfield, src->userfield);
 	dst->flags = src->flags;
 	copy_variables(&dst->variables, &src->variables);
@@ -1361,11 +1357,7 @@
 		struct ast_channel_snapshot *new_snapshot)
 {
 	cdr_object_update_cid(old_snapshot, new_snapshot);
-	if (old_snapshot->snapshot) {
-		ao2_t_ref(old_snapshot->snapshot, -1, "Drop ref for swap");
-	}
-	ao2_t_ref(new_snapshot, +1, "Bump ref for swap");
-	old_snapshot->snapshot = new_snapshot;
+	ao2_t_replace(old_snapshot->snapshot, new_snapshot, "Swap CDR shapshot");
 }
 
 /* BASE METHOD IMPLEMENTATIONS */

-- 
To view, visit https://gerrit.asterisk.org/6703
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 14
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f424f5282ca7d833592f958d95f1b2bafb549b0
Gerrit-Change-Number: 6703
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171009/b2d78484/attachment.html>


More information about the asterisk-code-review mailing list