diff th_datastruct.c @ 445:6d29aaeab290

Add new function th_strbuf_putsn().
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 19 Oct 2017 17:37:04 +0300
parents 2991e6b52d95
children efd33accdc81
line wrap: on
line diff
--- a/th_datastruct.c	Thu Oct 19 17:18:29 2017 +0300
+++ b/th_datastruct.c	Thu Oct 19 17:37:04 2017 +0300
@@ -568,6 +568,22 @@
 }
 
 
+BOOL th_strbuf_putsn(char **buf, size_t *bufsize, size_t *len, const char *str, const size_t slen)
+{
+    if (str == NULL)
+        return FALSE;
+
+    if (!th_strbuf_grow(buf, bufsize, len, slen + 1))
+        return FALSE;
+
+    memcpy(*buf + *len, str, slen);
+    (*len) += slen;
+    *(buf + *len + slen) = 0;
+
+    return TRUE;
+}
+
+
 BOOL th_strbuf_puts(char **buf, size_t *bufsize, size_t *len, const char *str)
 {
     size_t slen;