[Openvpn-devel,v1] push_util: use string_alloc() instead of a local gc_strdup()

Message ID 20261104174327.15221-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v1] push_util: use string_alloc() instead of a local gc_strdup() |

Commit Message

Gert Doering Nov. 4, 2026, 5:43 p.m. UTC
  From: Razvan Cojocaru <razvanc@mailbox.org>

gc_strdup() duplicated string_alloc() for its only caller. While here,
fix the typos in the message_splitter() comment.

Change-Id: Ib33ce23448959673affdfd462b4c2cfa9a015f55
Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2132
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2132
This mail reflects revision 1 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <frank@lichtenheld.com>
  

Patch

diff --git a/src/openvpn/push_util.c b/src/openvpn/push_util.c
index 34cb26c..0c27575 100644
--- a/src/openvpn/push_util.c
+++ b/src/openvpn/push_util.c
@@ -78,17 +78,8 @@ 
     return buf;
 }
 
-static char *
-gc_strdup(const char *src, struct gc_arena *gc)
-{
-    char *ret = gc_malloc((strlen(src) + 1) * sizeof(char), true, gc);
-
-    strcpy(ret, src);
-    return ret;
-}
-
-/* It split the messagge (if necessary) and fill msgs with the message chunks.
- * Return `false` on failure an `true` on success.
+/* Split the message (if necessary) and fill msgs with the message chunks.
+ * Return `false` on failure and `true` on success.
  */
 static bool
 message_splitter(const char *s, struct buffer_list *msgs, struct gc_arena *gc, const size_t safe_cap)
@@ -98,7 +89,7 @@ 
         return false;
     }
 
-    char *str = gc_strdup(s, gc);
+    char *str = string_alloc(s, gc);
 
     while (*str)
     {