diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/util.c | 19 | ||||
-rw-r--r-- | src/util.h | 3 |
2 files changed, 22 insertions, 0 deletions
@@ -22,6 +22,25 @@ #include "util.h" char * +mf_strdup(const char *src) +{ + size_t len; + char *dst; + + len = strlen(src); + + dst = malloc(len + 1 * sizeof(*dst)); + if (dst == NULL) { + return NULL; + } + + memcpy(dst, src, len); + dst[len] = '\0'; + + return dst; +} + +char * mf_strcat(const char *str1, const char *str2) { size_t str1_len; @@ -21,6 +21,9 @@ #define MF_UTIL_H_ char * +mf_strdup(const char *src); + +char * mf_strcat(const char *str1, const char *str2); #endif /* MF_UTIL_H_ */ |