diff options
Diffstat (limited to 'src/cd_util.c')
-rw-r--r-- | src/cd_util.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/cd_util.c b/src/cd_util.c index dadb6f4..1767ac4 100644 --- a/src/cd_util.c +++ b/src/cd_util.c @@ -333,3 +333,19 @@ char* cdStrDup(const char *str) } return NULL; } + +char* cdStrDupN(const char *str, int len) +{ + if (str) + { + int size = len+1; + char *newstr = malloc(size); + if (newstr) + { + memcpy(newstr, str, len); + newstr[len]=0; + } + return newstr; + } + return NULL; +} |