patch 9.1.1691: over-allocation in ga_concat_strings()

Commit: 
https://github.com/vim/vim/commit/0a9ad34cad8e104dd8eaf4c45af007bf049104e0
Author: Damien Lejay <dam...@lejay.be>
Date:   Tue Aug 26 17:55:14 2025 +0200

    patch 9.1.1691: over-allocation in ga_concat_strings()
    
    Problem:  over-allocation in ga_concat_strings()
    Solution: Fix ga_concat_strings() and only allocate n-1 separator length
              bytes (Damien Lejay).
    
    ga_concat_strings() was adding the separator length for every item,
    including the last one. Only (n - 1) separators are actually used.
    This caused harmless but unnecessary overallocation.
    
    closes: #18112
    
    Signed-off-by: Damien Lejay <dam...@lejay.be>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/alloc.c b/src/alloc.c
index 5f39085bc..386964c5b 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -770,7 +770,10 @@ ga_concat_strings(garray_T *gap, char *sep)
     char_u     *p;
 
     for (i = 0; i < gap->ga_len; ++i)
-       len += (int)STRLEN(((char_u **)(gap->ga_data))[i]) + sep_len;
+       len += (int)STRLEN(((char_u **)(gap->ga_data))[i]);
+
+    if (gap->ga_len > 1)
+       len += (gap->ga_len - 1) * sep_len;
 
     s = alloc(len + 1);
     if (s == NULL)
diff --git a/src/version.c b/src/version.c
index b0ce4f311..db3a4b7ac 100644
--- a/src/version.c
+++ b/src/version.c
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1691,
 /**/
     1690,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1uqw5e-003Xrz-CY%40256bit.org.

Raspunde prin e-mail lui