aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-10-19 15:32:22 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-10-19 15:32:22 +0200
commit9376361bcb8e323c7041d19895f967b5bf3ba038 (patch)
treed54c1519b1b04832a51b8eee5d112aaebf180bc3
parent1da12097cbf13eb85adb3d28533a4e1f62e2c882 (diff)
downloadslcl-9376361bcb8e323c7041d19895f967b5bf3ba038.tar.gz
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).
-rw-r--r--main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/main.c b/main.c
index df8cd21..ae501a3 100644
--- a/main.c
+++ b/main.c
@@ -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;