Remove needless mutex locks and unlocks

This commit is contained in:
kamkow1
2025-06-28 02:16:42 +02:00
parent 2e70abd0de
commit 48f4a73b0a
4 changed files with 3 additions and 36 deletions

19
baked.c
View File

@ -13,16 +13,6 @@ INCBIN(bundle_zip, "./bundle.zip");
static locked(Baked_Resource *) baked_resources = locked_init(nil);
void lock_baked_resources(void)
{
lockx(&baked_resources);
}
void unlock_baked_resources(void)
{
unlockx(&baked_resources);
}
void add_baked_resource(char *key, const uchar *data, size_t size)
{
int fd = memfd_create(key, 0);
@ -36,8 +26,6 @@ void add_baked_resource(char *key, const uchar *data, size_t size)
void init_baked_resources(void)
{
lockx(&baked_resources);
struct zip_t *zip = zip_stream_open(bundle_zip_data, bundle_zip_size, BUNDLE_ZIP_COMPRESSION, 'r');
size_t n = zip_entries_total(zip);
for (size_t i = 0; i < n; i++) {
@ -53,29 +41,28 @@ void init_baked_resources(void)
zip_entry_close(zip);
}
zip_stream_close(zip);
unlockx(&baked_resources);
}
void free_baked_resources(void)
{
lockx(&baked_resources);
for (size_t i = 0; i < shlen(baked_resources.value); i++) {
close(baked_resources.value[i].value.memfd);
free(baked_resources.value[i].key);
free(baked_resources.value[i].value.bufptr);
}
shfree(baked_resources.value);
unlockx(&baked_resources);
}
bool get_baked_resource_path(char *key, char *buf, size_t size)
{
lockx(&baked_resources);
if (shgeti(baked_resources.value, key) != -1) {
Baked_Resource_Value brv = shget(baked_resources.value, key);
snprintf(buf, size, "/proc/%d/fd/%d", getpid(), brv.memfd);
unlockx(&baked_resources);
return true;
}
unlockx(&baked_resources);
return false;
}