commit 5e96370
Devine Lu Linvega
·
2025-03-14 17:21:36 +0000 UTC
parent 65ee026
Use secondary buffer for putdir
3 files changed,
+20,
-17
+18,
-15
1@@ -41,6 +41,17 @@ typedef struct {
2 } UxnFile;
3
4 static UxnFile ufs[2];
5+static Uint8 dirbuf[0x10000], *_dirbuf = dirbuf;
6+
7+static void
8+make_pathfile(char *res, char *path, char *file)
9+{
10+ char c = '/';
11+ while(*path) c = *path++, *res = c, res++;
12+ if(c != DIRCHAR) *res = DIRCHAR, res++;
13+ while(*file) *res = *file++, res++;
14+ *res = 0;
15+}
16
17 static int
18 put_fill(Uint8 *dest, int len, char c)
19@@ -92,32 +103,24 @@ put_statfile(Uint8 *dest, const char *filepath, const char *basename)
20 return dest - anchor;
21 }
22
23-static void
24-make_pathfile(char *res, char *path, char *file)
25-{
26- char c = '/';
27- while(*path) c = *path++, *res = c, res++;
28- if(c != DIRCHAR) *res = DIRCHAR, res++;
29- while(*file) *res = *file++, res++;
30- *res = 0;
31-}
32-
33 static int
34 put_fdir(Uint8 *dest, unsigned int len, const char *filepath, DIR *dir)
35 {
36- Uint8 *_dest = dest;
37+ int i;
38 struct dirent *de = readdir(dir);
39- for(; de != NULL; de = readdir(dir)) {
40+ for(_dirbuf = dirbuf; de != NULL; de = readdir(dir)) {
41 char *name = de->d_name;
42 if(name[0] == '.' && (name[1] == '.' || name[1] == '\0'))
43 continue;
44- else if(len > strlen(name) + 8) {
45+ else {
46 static char res[0x2000];
47 make_pathfile(res, (char *)filepath, name);
48- dest += put_statfile(dest, res, name);
49+ _dirbuf += put_statfile(_dirbuf, res, name);
50 }
51 }
52- return dest - _dest;
53+ for(i = 0; i < len && dirbuf[i]; i++)
54+ dest[i] = dirbuf[i];
55+ return i;
56 }
57
58 static int
+1,
-1
1@@ -266,7 +266,7 @@ main(int argc, char **argv)
2 {
3 int i = 1;
4 if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
5- return !fprintf(stdout, "Uxn11 - Varvara Emulator, 7 Mar 2025.\n");
6+ return !fprintf(stdout, "Uxn11 - Varvara Emulator, 14 Mar 2025.\n");
7 else if(argc == 1)
8 return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
9 else if(!display_init())
+1,
-1
1@@ -48,7 +48,7 @@ main(int argc, char **argv)
2 {
3 int i = 1;
4 if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
5- return !fprintf(stdout, "Uxn(cli) - Varvara Emulator, 7 Mar 2025.\n");
6+ return !fprintf(stdout, "Uxn(cli) - Varvara Emulator, 14 Mar 2025.\n");
7 else if(argc == 1)
8 return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
9 else if(!system_boot((Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++], argc > 2))