From f2322ff942fabd55de0a1272b1fcca534e623bd1 Mon Sep 17 00:00:00 2001 From: Jussi Kivilinna Date: Sat, 12 Feb 2022 20:37:48 +0200 Subject: Use iobuf buffer size for temporary buffer size * common/iobuf.c (iobuf_copy): Use iobuf buffer size for temporary buffers. * g10/plaintext.c (handle_plaintext, do_hash): Likewise. * g10/sign.c (sign_file): Likewise. -- As iobuf will have zerocopy operation for read/write, it is better to use same size buffers as iobuf for temporary copy buffers. GnuPG-bug-id: T5828 Signed-off-by: Jussi Kivilinna --- common/iobuf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'common/iobuf.c') diff --git a/common/iobuf.c b/common/iobuf.c index ace745542..822eabe1a 100644 --- a/common/iobuf.c +++ b/common/iobuf.c @@ -2298,9 +2298,7 @@ size_t iobuf_copy (iobuf_t dest, iobuf_t source) { char *temp; - /* Use a 32 KB buffer. */ - const size_t temp_size = 32 * 1024; - + size_t temp_size; size_t nread; size_t nwrote = 0; size_t max_read = 0; @@ -2312,6 +2310,9 @@ iobuf_copy (iobuf_t dest, iobuf_t source) if (iobuf_error (dest)) return -1; + /* Use iobuf buffer size for temporary buffer. */ + temp_size = iobuf_set_buffer_size(0) * 1024; + temp = xmalloc (temp_size); while (1) { -- cgit v1.2.3