change switch_strip_spaces to specify if you want it to dup the string or destroy the current buffer

This commit is contained in:
Anthony Minessale
2010-12-21 20:30:19 -06:00
parent 638cbf16cc
commit 4d7e4f1ec2
6 changed files with 60 additions and 14 deletions

View File

@@ -831,9 +831,9 @@ SWITCH_DECLARE(char *) switch_strip_whitespace(const char *str)
return s;
}
SWITCH_DECLARE(char *) switch_strip_spaces(const char *str)
SWITCH_DECLARE(char *) switch_strip_spaces(char *str, switch_bool_t dup)
{
const char *sp = str;
char *sp = str;
char *p, *s = NULL;
if (!sp)
@@ -843,7 +843,11 @@ SWITCH_DECLARE(char *) switch_strip_spaces(const char *str)
sp++;
}
s = strdup(sp);
if (dup) {
s = strdup(sp);
} else {
s = sp;
}
if (!s)
return NULL;