Replace mstrcpy, mstrncpy with strdup, strndup

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2018-12-15 19:07:14 +00:00
parent b8912fa749
commit b73dce1d6d
7 changed files with 20 additions and 44 deletions

View File

@@ -3,28 +3,6 @@
#include "compiler.h"
#include "string_utils.h"
#include "utils.h"
/**
* Allocate the space and copy a string.
*/
char *mstrcpy(const char *src) {
auto str = ccalloc(strlen(src) + 1, char);
strcpy(str, src);
return str;
}
/**
* Allocate the space and copy a string.
*/
char *mstrncpy(const char *src, unsigned len) {
auto str = ccalloc(len + 1, char);
strncpy(str, src, len);
str[len] = '\0';
return str;
}
/**
* Allocate the space and join two strings.