main.c: Use BUFSIZ instead of arbitrary value

According to C99 7.19.1p3:

BUFSIZ is a macro that expands to an integer constant expression that is
the size of the buffer used by the setbuf function.

In other words, this means BUFSIZ is the most optimal length for a
buffer that reads a file into memory in chunks using fread(3).
This commit is contained in:
Xavier Del Campo Romero 2023-10-19 15:32:22 +02:00
parent 1da12097cb
commit 9376361bcb
Signed by: xavi
GPG Key ID: 84FF3612A9BF43F2
1 changed files with 1 additions and 1 deletions

2
main.c
View File

@ -1060,7 +1060,7 @@ static int move_file(const char *const old, const char *const new)
for (off_t i = 0; i < sb.st_size;)
{
char buf[1024];
char buf[BUFSIZ];
const off_t left = sb.st_size - i;
const size_t rem = left > sizeof buf ? sizeof buf : left;
ssize_t w;