mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
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: https://origsvn.digium.com/svn/asterisk/branches/1.4@90348 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user