Skip to content

Commit e9fdc25

Browse files
committed
reduce stack usage prior to recursive CopyTree so more stack available for recursion (move larger buffers to static variables on heap)
1 parent c56d243 commit e9fdc25

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/movedir.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ static int CopyTree(int depth, char *src_pathname,
228228
/* find first source file */
229229
strmcpy(filepattern, src_pathname, sizeof(filepattern));
230230
strmcat(filepattern, src_filename, sizeof(filepattern));
231-
done = findfirst(filepattern, &fileblock, fileattrib);
231+
done = findfirst(filepattern, fileblock, fileattrib);
232232

233233
/* check if destination directory must be created */
234234
if (!dir_exists(dest_pathname))
@@ -308,10 +308,10 @@ static int xcopy_file(const char *src_filename,
308308

309309
int MoveDirectory(const char* src_filename, const char* dest_filename)
310310
{
311-
char src_path[MAXPATH], src_file[MAXPATH];
312-
char dest_path[MAXPATH],dest_file[MAXPATH];
311+
static char src_path[MAXPATH], src_file[MAXPATH];
312+
static char dest_path[MAXPATH],dest_file[MAXPATH];
313313

314-
char drive[MAXDRIVE], dir[MAXDIR], fname[MAXFILE], ext[MAXEXT];
314+
static char drive[MAXDRIVE], dir[MAXDIR], fname[MAXFILE], ext[MAXEXT];
315315

316316
SplitPath(src_filename, drive, dir, fname, ext);
317317

@@ -339,7 +339,7 @@ int MoveDirectory(const char* src_filename, const char* dest_filename)
339339
}
340340
if (dir_exists(dest_filename))
341341
if (!DelTree(dest_filename))
342-
return 0;
342+
return 0;
343343

344344
if (!CopyTree(0, src_path, src_file, dest_path, dest_file))
345345
{

0 commit comments

Comments
 (0)