Initialize

This commit is contained in:
2021-12-16 09:29:17 +08:00
commit 6e0f72d7ed
22 changed files with 1550 additions and 0 deletions

17
cstr_util.c Normal file
View File

@@ -0,0 +1,17 @@
#include "cstr_util.h"
#include <malloc.h>
#include <string.h>
int cstr_util_copy_str(char** dest, const char* str) {
if (!dest || !str) return 1;
size_t le = strlen(str);
char* temp = malloc(le + 1);
if (!temp) {
return 2;
}
memcpy(temp, str, le);
temp[le] = 0;
*dest = temp;
return 0;
}