]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Use p_realloc_type() where possible
authoruwezkhan06 <uwezkhan053@gmail.com>
Tue, 21 Apr 2026 20:27:38 +0000 (20:27 +0000)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Sat, 2 May 2026 05:30:11 +0000 (05:30 +0000)
src/lib/strescape.c
src/lib/strfuncs.c

index ded3d4bf17af515eab19ad48cc14f06ce403a73c..b62a5c779a2215ae44ff4b50645da6eb8926d592 100644 (file)
@@ -320,12 +320,8 @@ static char **p_strsplit_tabescaped_inplace(pool_t pool, char *data)
                }
                if (count+1 >= alloc_count) {
                        new_alloc_count = nearest_power(alloc_count+1);
-                       size_t old_size =
-                               MALLOC_MULTIPLY(sizeof(char *), alloc_count);
-                       size_t new_size =
-                               MALLOC_MULTIPLY(sizeof(char *), new_alloc_count);
-                       array = p_realloc(pool, array,
-                                         old_size, new_size);
+                       array = p_realloc_type(pool, array, char *,
+                                              alloc_count, new_alloc_count);
                        alloc_count = new_alloc_count;
                }
                *data++ = '\0';
index 2b346f61ec13d98addc2950990111b16747e448c..7ff107101800a7afebf759f86e87c43215c05fad 100644 (file)
@@ -758,12 +758,8 @@ split_str_slow(pool_t pool, const char *data, const char *separators, bool space
                        /* separator found */
                        if (count+1 >= alloc_count) {
                                new_alloc_count = nearest_power(alloc_count+1);
-                               size_t old_size =
-                                       MALLOC_MULTIPLY(sizeof(char *), alloc_count);
-                               size_t new_size =
-                                       MALLOC_MULTIPLY(sizeof(char *), new_alloc_count);
-                               array = p_realloc(pool, array,
-                                                 old_size, new_size);
+                               array = p_realloc_type(pool, array, char *,
+                                                      alloc_count, new_alloc_count);
                                alloc_count = new_alloc_count;
                        }
 
@@ -809,12 +805,8 @@ split_str_fast(pool_t pool, const char *data, char sep)
                /* separator found */
                if (count+1 >= alloc_count) {
                        new_alloc_count = nearest_power(alloc_count+1);
-                       size_t old_size =
-                               MALLOC_MULTIPLY(sizeof(char *), alloc_count);
-                       size_t new_size =
-                               MALLOC_MULTIPLY(sizeof(char *), new_alloc_count);
-                       array = p_realloc(pool, array,
-                                         old_size, new_size);
+                       array = p_realloc_type(pool, array, char *,
+                                              alloc_count, new_alloc_count);
                        alloc_count = new_alloc_count;
                }
                *str++ = '\0';