[Libguestfs] [PATCH libnbd v2 6/8] lib/crypto.c: Simplify vector reserve

Nir Soffer nsoffer at redhat.com
Sun Oct 31 15:38:55 UTC 2021


We don't need to worry now about efficient growing.

Signed-off-by: Nir Soffer <nsoffer at redhat.com>
---
 lib/crypto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/crypto.c b/lib/crypto.c
index f570db3..2ce4d4d 100644
--- a/lib/crypto.c
+++ b/lib/crypto.c
@@ -150,7 +150,7 @@ nbd_unlocked_get_tls_username (struct nbd_handle *h)
       return NULL;
     }
     /* Try again with a larger buffer. */
-    if (string_reserve (&str, str.cap == 0 ? 16 : str.cap * 2) == -1) {
+    if (string_reserve (&str, 16) == -1) {
       set_error (errno, "realloc");
       free (str.ptr);
       return NULL;
-- 
2.31.1




More information about the Libguestfs mailing list