]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/util: add talloc_alpha_strcpy()
authorRalph Boehme <slow@samba.org>
Fri, 17 Jan 2020 18:15:22 +0000 (19:15 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Thu, 6 Feb 2020 10:17:42 +0000 (10:17 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/util/charset/charset.h
lib/util/util_str_common.c

index ff466c34bb91b0c6b22448994b6300a88b1f945a..ef7911a62546d9e72810cb4c4be56b9ecf4731b8 100644 (file)
@@ -112,6 +112,9 @@ size_t strlen_m(const char *s);
 size_t strlen_m_term(const char *s);
 size_t strlen_m_term_null(const char *s);
 char *alpha_strcpy(char *dest, const char *src, const char *other_safe_chars, size_t maxlength);
+char *talloc_alpha_strcpy(TALLOC_CTX *mem_ctx,
+                         const char *src,
+                         const char *other_safe_chars);
 void string_replace_m(char *s, char oldc, char newc);
 bool strcsequal(const char *s1,const char *s2);
 bool strequal_m(const char *s1, const char *s2);
index 0933e183c8063681127e3ce8a389b631b22ed3a7..1e93a46fbad115ad900ee1d8e1f62ca60784a19a 100644 (file)
@@ -159,3 +159,25 @@ char *alpha_strcpy(char *dest,
 
        return dest;
 }
+
+char *talloc_alpha_strcpy(TALLOC_CTX *mem_ctx,
+                         const char *src,
+                         const char *other_safe_chars)
+{
+       char *dest = NULL;
+       size_t slen;
+
+       if (src == NULL) {
+               return NULL;
+       }
+
+       slen = strlen(src);
+
+       dest = talloc_zero_size(mem_ctx, slen + 1);
+       if (dest == NULL) {
+               return NULL;
+       }
+
+       alpha_strcpy(dest, src, other_safe_chars, slen + 1);
+       return dest;
+}