From 79266500cd3f84c74b2f89ceeb15c23cedacc2b5 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 12 Nov 2007 15:02:50 -0800 Subject: Remove all pstrings from smbd/chgpasswd.c. Jeremy. (This used to be commit eaf14c701b08e9eff5b94bf57af68cb29142d7fc) --- source3/lib/util_str.c | 64 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 20 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index f1078c6383..6d429e3719 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -1254,22 +1254,27 @@ char *realloc_string_sub(char *string, const char *pattern, return string; } -/* Same as string_sub, but returns a talloc'ed string */ +/* + * Internal guts of talloc_string_sub and talloc_all_string_sub. + * 'filter' differentiates between them. + */ -char *talloc_string_sub(TALLOC_CTX *mem_ctx, const char *src, - const char *pattern, const char *insert) +static char *talloc_string_sub_internal(TALLOC_CTX *mem_ctx, const char *src, + const char *pattern, const char *insert, bool filter) { char *p, *in; char *s; char *string; ssize_t ls,lp,li,ld, i; - if (!insert || !pattern || !*pattern || !src || !*src) + if (!insert || !pattern || !*pattern || !src || !*src) { return NULL; + } string = talloc_strdup(mem_ctx, src); if (string == NULL) { - DEBUG(0, ("talloc_strdup failed\n")); + DEBUG(0, ("talloc_string_sub_internal: " + "talloc_strdup failed\n")); return NULL; } @@ -1277,27 +1282,30 @@ char *talloc_string_sub(TALLOC_CTX *mem_ctx, const char *src, in = SMB_STRDUP(insert); if (!in) { - DEBUG(0, ("talloc_string_sub: out of memory!\n")); + DEBUG(0, ("talloc_string_sub_internal: ENOMEM\n")); return NULL; } ls = (ssize_t)strlen(s); lp = (ssize_t)strlen(pattern); li = (ssize_t)strlen(insert); ld = li - lp; - for (i=0;i