Rename __zipos_free -> __zipos_drop (#1043)

Removes the separate decref function, uses keep/drop in the internal
API.
This commit is contained in:
Jōshin 2023-12-26 12:08:57 -05:00 committed by GitHub
parent fd772b9b2a
commit 5c35863524
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 15 deletions

View file

@ -88,18 +88,11 @@ struct ZiposHandle *__zipos_keep(struct ZiposHandle *h) {
return h;
}
static bool __zipos_drop(struct ZiposHandle *h) {
if (!atomic_fetch_sub_explicit(&h->refs, 1, memory_order_release)) {
atomic_thread_fence(memory_order_acquire);
return true;
}
return false;
}
void __zipos_free(struct ZiposHandle *h) {
if (!__zipos_drop(h)) {
void __zipos_drop(struct ZiposHandle *h) {
if (atomic_fetch_sub_explicit(&h->refs, 1, memory_order_release)) {
return;
}
atomic_thread_fence(memory_order_acquire);
if (IsAsan()) {
__asan_poison((char *)h + sizeof(struct ZiposHandle),
h->mapsize - sizeof(struct ZiposHandle), kAsanHeapFree);
@ -227,7 +220,7 @@ static int __zipos_load(struct Zipos *zipos, size_t cf, int flags,
}
__fds_unlock();
}
__zipos_free(h);
__zipos_drop(h);
return -1;
}
@ -238,7 +231,7 @@ void __zipos_postdup(int oldfd, int newfd) {
BLOCK_SIGNALS;
__fds_lock();
if (__isfdkind(newfd, kFdZip)) {
__zipos_free((struct ZiposHandle *)(intptr_t)g_fds.p[newfd].handle);
__zipos_drop((struct ZiposHandle *)(intptr_t)g_fds.p[newfd].handle);
if (!__isfdkind(oldfd, kFdZip)) {
bzero(g_fds.p + newfd, sizeof(*g_fds.p));
}