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

Richard Mudgett asteriskteam at digium.com
Mon Oct 9 13:30:07 CDT 2017


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


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/04/6704/1

diff --git a/main/cdr.c b/main/cdr.c
index 1817e80..1a3ff87 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -751,11 +751,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);
@@ -1358,11 +1354,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/6704
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I9f424f5282ca7d833592f958d95f1b2bafb549b0
Gerrit-Change-Number: 6704
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/eb2bb366/attachment.html>


More information about the asterisk-code-review mailing list