Skip to content

Instantly share code, notes, and snippets.

@yfrancis
Created October 19, 2012 10:10
Show Gist options
  • Save yfrancis/3917300 to your computer and use it in GitHub Desktop.
Save yfrancis/3917300 to your computer and use it in GitHub Desktop.
void
WSRelease(WSTypeRef obj)
{
WSIndex orig = obj->retainCount;
while (!OSAtomicDecrement32Barrier((int32_t*)&obj->retainCount));
if (orig == 1 && !obj->retainCount)
free(obj);
}
@mringwal
Copy link

int32_t newCount = OSAtomicDecrement32Barrier((int32_t*)&obj->retainCount));
if (!newCount) {
free(obj);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment