diff options
Diffstat (limited to 'MemoryManager.c')
| -rw-r--r-- | MemoryManager.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/MemoryManager.c b/MemoryManager.c index 98e70e7..53f906e 100644 --- a/MemoryManager.c +++ b/MemoryManager.c @@ -1,6 +1,7 @@ #include "MemoryManager.h" #include "Types.h" #include <stdlib.h> +#include <string.h> Result std_alloc(MemoryManager mm, void **ptr, usize size) { @@ -44,3 +45,19 @@ M_std() { .destroy = &std_destroy, }; } + +char* +M_strdup(MemoryManager mm, const char* str) { + if (NULL == str) + return NULL; + + char* newstr = NULL; + if (R_Ok != mm.alloc(mm, (void**)&newstr, strlen(str) + 1) || + NULL == newstr) + { + return NULL; + } + + strcpy(newstr, str); + return newstr; +} |
