diff options
author | Simo Sorce <idra@samba.org> | 2004-08-12 06:30:03 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:57:54 -0500 |
commit | d01bc8a91e90a818786b46625249fc38ead7be4d (patch) | |
tree | f9d50101564de25c9100dfca77a823fb96afca68 /source4/lib/util_str.c | |
parent | e2357c67f5afbfeacafab6997b57ea262cd3c05a (diff) | |
download | samba-d01bc8a91e90a818786b46625249fc38ead7be4d.tar.gz samba-d01bc8a91e90a818786b46625249fc38ead7be4d.tar.xz samba-d01bc8a91e90a818786b46625249fc38ead7be4d.zip |
r1758: Move and enhance the add_string_to_array function as per volker job on trunk
(This used to be commit 606caddeb95382287fa41a5017ca473d0301be6b)
Diffstat (limited to 'source4/lib/util_str.c')
-rw-r--r-- | source4/lib/util_str.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/source4/lib/util_str.c b/source4/lib/util_str.c index 66acc0ca0e..fd13f86501 100644 --- a/source4/lib/util_str.c +++ b/source4/lib/util_str.c @@ -1446,3 +1446,21 @@ const char *str_format_nbt_domain(TALLOC_CTX *mem_ctx, const char *s) return ret; } + +BOOL add_string_to_array(TALLOC_CTX *mem_ctx, + const char *str, const char ***strings, int *num) +{ + char *dup_str = talloc_strdup(mem_ctx, str); + + *strings = talloc_realloc(mem_ctx, *strings, + ((*num)+1) * sizeof(**strings)); + + if ((*strings == NULL) || (dup_str == NULL)) + return False; + + (*strings)[*num] = dup_str; + *num += 1; + + return True; +} + |