Work in progress

Refactoring cstr_copy and adding test
This commit is contained in:
Michael Tryby
2019-04-16 15:51:19 -04:00
parent ac56971ef2
commit 02ec735c58
4 changed files with 31 additions and 12 deletions

View File

@@ -17,13 +17,10 @@
#include "cstr_helper.h"
int cstr_copy(const char *source, char **dest)
// Determines length, allocates memory, and returns a null terminated copy
// Be Aware: caller is responsible for freeing memory
int cstr_duplicate(char **dest, const char *source)
// Duplicates source string
{
size_t size;
size = 1 + strlen(source);
size_t size = 1 + strlen(source);
*dest = (char *) calloc(size, sizeof(char));
if (*dest == NULL)