2018-03-07 10:30:40 +01:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2018-03-11 00:56:41 +01:00
|
|
|
/**
|
|
|
|
* @brief Duplicate a string
|
|
|
|
* @param s string to duplicate
|
|
|
|
* @return duplicated string, the memory acllocated has to be freed by #free.
|
|
|
|
*/
|
2018-03-07 10:30:40 +01:00
|
|
|
char *cw_strdup(const char *s) {
|
|
|
|
size_t size = strlen(s) + 1;
|
|
|
|
char *p = malloc(size);
|
|
|
|
if (p)
|
|
|
|
memcpy(p, s, size);
|
|
|
|
return p;
|
|
|
|
}
|