mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Rename __zipos_free -> __zipos_drop (#1043)
Removes the separate decref function, uses keep/drop in the internal API.
This commit is contained in:
parent
fd772b9b2a
commit
5c35863524
4 changed files with 8 additions and 15 deletions
|
@ -39,7 +39,7 @@ int __zipos_close(int fd) {
|
|||
if (!__vforked) {
|
||||
struct ZiposHandle *h;
|
||||
h = (struct ZiposHandle *)(intptr_t)g_fds.p[fd].handle;
|
||||
__zipos_free(h);
|
||||
__zipos_drop(h);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
.yoink __zipos_mmap
|
||||
.yoink __zipos_postdup
|
||||
.yoink __zipos_keep
|
||||
.yoink __zipos_free
|
||||
.yoink __zipos_drop
|
||||
|
||||
// TODO(jart): why does corruption happen when zip has no assets?
|
||||
.yoink .cosmo
|
||||
|
|
|
@ -38,7 +38,7 @@ struct Zipos {
|
|||
};
|
||||
|
||||
int __zipos_close(int);
|
||||
void __zipos_free(struct ZiposHandle *);
|
||||
void __zipos_drop(struct ZiposHandle *);
|
||||
struct ZiposHandle *__zipos_keep(struct ZiposHandle *);
|
||||
struct Zipos *__zipos_get(void) pureconst;
|
||||
size_t __zipos_normpath(char *, const char *, size_t);
|
||||
|
|
Loading…
Reference in a new issue