Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions libc-bottom-half/sources/preopens.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,13 @@ static void assert_invariants(void) {

/// Allocate space for more preopens. Returns 0 on success and -1 on failure.
static int resize(void) {
LOCK(lock);
size_t start_capacity = 4;
size_t old_capacity = preopen_capacity;
size_t new_capacity = old_capacity == 0 ? start_capacity : old_capacity * 2;

preopen *old_preopens = preopens;
preopen *new_preopens = calloc(sizeof(preopen), new_capacity);
if (new_preopens == NULL) {
UNLOCK(lock);
return -1;
}

Expand All @@ -77,7 +75,6 @@ static int resize(void) {
free(old_preopens);

assert_invariants();
UNLOCK(lock);
return 0;
}

Expand All @@ -101,8 +98,7 @@ static const char *strip_prefixes(const char *path) {
return path;
}

/// Similar to `internal_register_preopened_fd_unlocked` but does not
/// take a lock.
/// Similar to `internal_register_preopened_fd` but does not take a lock.
static int internal_register_preopened_fd_unlocked(__wasi_fd_t fd, const char *relprefix) {
// Check preconditions.
assert_invariants();
Expand Down