Skip to content

Commit

Permalink
Use the old association policy to determine whether to release an object
Browse files Browse the repository at this point in the history
This commit has been augmented to address the comments in
df7f906
  • Loading branch information
DHowett committed Jan 22, 2018
1 parent 7a226d8 commit 0b2cfdc
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions associate.m
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,17 @@ static void setReference(struct reference_list *list,
lock = lock_for_pointer(r);
lock_spinlock(lock);
}
r->policy = policy;
id old = r->object;
r->object = obj;
if (OBJC_ASSOCIATION_ASSIGN != r->policy)
@try
{
objc_release(old);
if (OBJC_ASSOCIATION_ASSIGN != r->policy)
{
objc_release(r->object);
}
}
@finally
{
r->policy = policy;
r->object = obj;
}
if (needLock)
{
Expand Down

0 comments on commit 0b2cfdc

Please sign in to comment.