Skip to content

Commit 713670d

Browse files
committed
Use smaller buffer for copying
1 parent 3d2db84 commit 713670d

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

testsuite/testsuite.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ int rem_file(const char* fileName)
778778

779779
int copy_file(const char* in, const char* out)
780780
{
781-
byte buf[2500];
781+
byte buf[100];
782782
XFILE inFile = XBADFILE;
783783
XFILE outFile = XBADFILE;
784784
size_t sz;
@@ -792,14 +792,10 @@ int copy_file(const char* in, const char* out)
792792
if (outFile == XBADFILE)
793793
goto cleanup;
794794

795-
sz = XFREAD(buf, 1, sizeof(buf), inFile);
796-
/* 2500 bytes should be more than enough to read the entire files.
797-
* Error out if we can't read the file all at once. */
798-
if (sz == sizeof(buf) || sz == 0)
799-
goto cleanup;
800-
801-
if (XFWRITE(buf, 1, sz, outFile) != sz)
802-
goto cleanup;
795+
while ((sz = XFREAD(buf, 1, sizeof(buf), inFile)) != 0) {
796+
if (XFWRITE(buf, 1, sz, outFile) != sz)
797+
goto cleanup;
798+
}
803799

804800
ret = 0;
805801
cleanup:

0 commit comments

Comments
 (0)