diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-11-30 19:26:04 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-11-30 19:26:04 +0000 |
commit | 213a686818ae3b52921ac398852d0ffdff4f5f73 (patch) | |
tree | 9cb3c976f72d1999221cfb9a689ea8d7929fa8ad /main/astobj2.c | |
parent | 64fb113167810bc0f1d1310f205d23b687ef8f18 (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/astobj2.c')
-rw-r--r-- | main/astobj2.c | 1 |
1 files changed, 1 insertions, 0 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; |