From 33067b728633b0c6ac89d4cce9d66edacbab8cf1 Mon Sep 17 00:00:00 2001 From: Nishi Date: Wed, 9 Oct 2024 10:49:15 +0000 Subject: [PATCH] c89 git-svn-id: file:///raid/svn-personal/tewi/trunk@292 8739d7e6-ffea-ec47-b151-bdff447c6205 --- Common/dir.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Common/dir.c b/Common/dir.c index 716f6e2..0a27687 100644 --- a/Common/dir.c +++ b/Common/dir.c @@ -71,6 +71,9 @@ char** cm_scandir(const char* path) { if(dir != NULL) { char** r = malloc(sizeof(*r)); struct dirent* d; + char** old; + int len; + int i; r[0] = NULL; while((d = readdir(dir)) != NULL) { if(strcmp(d->d_name, ".") != 0 && strcmp(d->d_name, "..") != 0) { @@ -79,8 +82,7 @@ char** cm_scandir(const char* path) { stat(p, &s); free(p); - char** old = r; - int i; + old = r; for(i = 0; old[i] != NULL; i++) ; r = malloc(sizeof(*r) * (i + 2)); @@ -90,13 +92,11 @@ char** cm_scandir(const char* path) { free(old); } } - int len; for(len = 0; r[len] != NULL; len++) ; qsort(r, len, sizeof(char*), cm_sort); - char** old = r; - int i; + old = r; for(i = 0; old[i] != NULL; i++) ; r = malloc(sizeof(*r) * (i + 2)); -- 2.43.0