File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -150,14 +150,13 @@ int _wasmfs_symlink(char* old_path, char* new_path) {
150
150
}
151
151
152
152
intptr_t _wasmfs_readlink (char * path) {
153
- static thread_local void * readBuf = nullptr ;
154
- readBuf = realloc (readBuf, PATH_MAX);
153
+ static thread_local char * readBuf = (char *)malloc (PATH_MAX);
155
154
int bytes =
156
155
__syscall_readlinkat (AT_FDCWD, (intptr_t )path, (intptr_t )readBuf, PATH_MAX);
157
156
if (bytes < 0 ) {
158
157
return bytes;
159
158
}
160
- (( char *) readBuf) [bytes] = ' \0 ' ;
159
+ readBuf[bytes] = ' \0 ' ;
161
160
return (intptr_t )readBuf;
162
161
}
163
162
@@ -350,9 +349,8 @@ void _wasmfs_readdir_finish(struct wasmfs_readdir_state* state) {
350
349
351
350
char * _wasmfs_get_cwd (void ) {
352
351
// TODO: PATH_MAX is 4K atm, so it might be good to reduce this somehow.
353
- static thread_local void * path = nullptr ;
354
- path = realloc (path, PATH_MAX);
355
- return getcwd ((char *)path, PATH_MAX);
352
+ static thread_local char * path = (char *)malloc (PATH_MAX);
353
+ return getcwd (path, PATH_MAX);
356
354
}
357
355
358
356
} // extern "C"
You can’t perform that action at this time.
0 commit comments