cdr.c: Replace inlined code with ao2_t_replace()
authorRichard Mudgett <rmudgett@digium.com>
Mon, 2 Oct 2017 22:41:12 +0000 (17:41 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Mon, 9 Oct 2017 18:30:16 +0000 (13:30 -0500)
Change-Id: I9f424f5282ca7d833592f958d95f1b2bafb549b0

main/cdr.c

index 1817e80..1a3ff87 100644 (file)
@@ -751,11 +751,7 @@ static void free_variables(struct varshead *headp)
  */
 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 @@ static void cdr_object_swap_snapshot(struct cdr_object_snapshot *old_snapshot,
                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 */