diff options
Diffstat (limited to 'utils/dupstr.c')
-rw-r--r-- | utils/dupstr.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/utils/dupstr.c b/utils/dupstr.c new file mode 100644 index 00000000..fd79583f --- /dev/null +++ b/utils/dupstr.c @@ -0,0 +1,19 @@ +/* + * Allocate a duplicate of an ordinary C NUL-terminated string. + */ + +#include <string.h> + +#include "defs.h" +#include "misc.h" + +char *dupstr(const char *s) +{ + char *p = NULL; + if (s) { + int len = strlen(s); + p = snewn(len + 1, char); + strcpy(p, s); + } + return p; +} |