Skip to content

Commit 47904b6

Browse files
committed
further reduction of initial stack usage so more stack available
1 parent e9fdc25 commit 47904b6

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/move.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ static void move_files(const char *src_pathname, const char *src_filename,
316316
const char *dest_pathname, const char *dest_filename,
317317
int movedirs)
318318
{
319-
char filepattern[MAXPATH],src_path_filename[MAXPATH],dest_path_filename[MAXPATH];
320-
char tmp_filename[MAXFILE+MAXEXT],tmp_pathname[MAXPATH];
321-
struct ffblk fileblock;
319+
static char filepattern[MAXPATH],src_path_filename[MAXPATH],dest_path_filename[MAXPATH];
320+
static char tmp_filename[MAXFILE+MAXEXT],tmp_pathname[MAXPATH];
321+
static struct ffblk fileblock;
322322
unsigned fileattrib;
323323
int done;
324324

src/movedir.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ static int DelTree(const char* path)
172172
/*-------------------------------------------------------------------------*/
173173
/* Searchs through the source directory (and its subdirectories) and calls */
174174
/* function "xcopy_file" for every found file. */
175+
/* Note: can use up to 40 bytes stack per call with Borland C */
175176
/*-------------------------------------------------------------------------*/
176177
static int CopyTree(int depth, char *src_pathname,
177178
const char *src_filename,
@@ -181,11 +182,10 @@ static int CopyTree(int depth, char *src_pathname,
181182
char * old_new_src_pathname = src_pathname + strlen(src_pathname);
182183
char * old_new_dest_pathname = dest_pathname + strlen(dest_pathname);
183184
/* Warning: these are overwritten during recursive calls */
184-
static char filepattern[MAXPATH],
185+
static char path_pattern_buf[MAXPATH],
185186
src_path_filename[MAXPATH],
186187
dest_path_filename[MAXPATH],
187-
tmp_filename[MAXFILE + MAXEXT],
188-
tmp_pathname[MAXPATH];
188+
tmp_filename[MAXFILE + MAXEXT];
189189
struct ffblk *fileblock;
190190
unsigned fileattrib;
191191
int done;
@@ -195,9 +195,9 @@ static int CopyTree(int depth, char *src_pathname,
195195
error(1,30,"Insufficient memory");
196196
return 0;
197197
}
198-
strmcpy(filepattern, src_pathname, sizeof(filepattern));
199-
strmcat(filepattern, src_filename, sizeof(filepattern));
200-
done = findfirst(filepattern, fileblock, FA_DIREC);
198+
strmcpy(path_pattern_buf, src_pathname, sizeof(path_pattern_buf));
199+
strmcat(path_pattern_buf, src_filename, sizeof(path_pattern_buf));
200+
done = findfirst(path_pattern_buf, fileblock, FA_DIREC);
201201
while (!done)
202202
{
203203
if (fileblock->ff_attrib == FA_DIREC &&
@@ -226,16 +226,16 @@ static int CopyTree(int depth, char *src_pathname,
226226
fileattrib = FA_RDONLY+FA_ARCH+FA_HIDDEN+FA_SYSTEM;
227227

228228
/* find first source file */
229-
strmcpy(filepattern, src_pathname, sizeof(filepattern));
230-
strmcat(filepattern, src_filename, sizeof(filepattern));
231-
done = findfirst(filepattern, fileblock, fileattrib);
229+
strmcpy(path_pattern_buf, src_pathname, sizeof(path_pattern_buf));
230+
strmcat(path_pattern_buf, src_filename, sizeof(path_pattern_buf));
231+
done = findfirst(path_pattern_buf, fileblock, fileattrib);
232232

233233
/* check if destination directory must be created */
234234
if (!dir_exists(dest_pathname))
235235
{
236-
strmcpy(tmp_pathname, dest_pathname, sizeof(tmp_pathname));
236+
strmcpy(path_pattern_buf, dest_pathname, sizeof(path_pattern_buf));
237237

238-
if (makedir(tmp_pathname) != 0)
238+
if (makedir(path_pattern_buf) != 0)
239239
{
240240
error(1,28,"Unable to create directory");
241241
return 0;

0 commit comments

Comments
 (0)