We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3dda4f1 commit d6e040eCopy full SHA for d6e040e
include/libc/unix/posixio.c
@@ -243,10 +243,17 @@ int _find_free_file()
243
}
244
245
/* get a new vfs file handle */
246
+/* only used internally, and prefers bigger handles
247
+ so as not to conflict with BASIC hardcoded integers
248
+*/
249
+
250
vfs_file_t *
251
_get_vfs_file_handle()
252
{
- int fd = _find_free_file();
253
+ int fd;
254
+ for (fd = _MAX_FILES-1; fd >= 0; --fd) {
255
+ if (__filetab[fd].state == 0) break;
256
+ }
257
if (fd < 0) return 0;
258
return &__filetab[fd];
259
0 commit comments