aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-30 19:26:04 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-11-30 19:26:04 +0000
commit213a686818ae3b52921ac398852d0ffdff4f5f73 (patch)
tree9cb3c976f72d1999221cfb9a689ea8d7929fa8ad /main
parent64fb113167810bc0f1d1310f205d23b687ef8f18 (diff)
Change the behavior of ao2_link(). Previously, in inherited a reference.
Now, it automatically increases the reference count to reflect the reference that is now held by the container. This was done to be more consistent with ao2_unlink(), which automatically releases the reference held by the container. It also makes it so it is no longer possible for a pointer to be invalid after ao2_link() returns. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@90348 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/astobj2.c1
-rw-r--r--main/manager.c2
2 files changed, 1 insertions, 2 deletions
diff --git a/main/astobj2.c b/main/astobj2.c
index 4b82eaf92..7cbf70cce 100644
--- a/main/astobj2.c
+++ b/main/astobj2.c
@@ -365,6 +365,7 @@ void *__ao2_link(struct ao2_container *c, void *user_data, int iax2_hack)
else
AST_LIST_INSERT_TAIL(&c->buckets[i], p, entry);
ast_atomic_fetchadd_int(&c->elements, 1);
+ ao2_ref(user_data, +1);
ao2_unlock(c);
return p;
diff --git a/main/manager.c b/main/manager.c
index cecb2ca89..830634792 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -394,8 +394,6 @@ static char *xml_translate(char *in, struct ast_variable *vars)
vc = ao2_alloc(sizeof(*vc), NULL);
vc->varname = var;
vc->count = 1;
- /* Increment refcount, because we're going to deref once later */
- ao2_ref(vc, 1);
ao2_link(vco, vc);
}