Skip to content
Snippets Groups Projects
Commit 1935e6df authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Moved the alloca in f_get_dir out of the loop.

Doesn't throw an error when reaching the end of the directory any longer..

Rev: src/modules/files/efuns.c:1.10
parent 6f830e08
Branches
Tags
No related merge requests found
......@@ -182,19 +182,19 @@ void f_get_dir(INT32 args)
char buffer[MAXPATHLEN * 4];
char *ptrs[FPR];
int lens[FPR];
struct dirent *tmp;
if (!(tmp = alloca(sizeof(struct dirent) +
pathconf(path, _PC_NAME_MAX) + 1))) {
error("get_dir(): Out of memory!\n");
}
while(1)
{
int e;
struct dirent *tmp;
int num_files=0;
char *bufptr=buffer;
if (!(tmp = alloca(sizeof(struct dirent) +
pathconf(path, _PC_NAME_MAX) + 1))) {
error("get_dir(): Out of memory!\n");
}
THREADS_ALLOW();
while(1)
......@@ -220,7 +220,7 @@ void f_get_dir(INT32 args)
num_files++;
}
THREADS_DISALLOW();
if (!d) {
if ((!d) && (errno != ENOENT)) {
error("get_dir(): readdir_r() failed: %d\n", errno);
}
for(e=0;e<num_files;e++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment