From 4718bcf3bb6be8329fe90d7f324eac74c687e9ff Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Mon, 26 Mar 2018 07:39:54 +0000 Subject: [PATCH] Reformatted FossilOrigin-Name: 4e99b5c4df0169dc245e94f880fc771b028bf0226aa639cc5077f0062de5cb9c --- src/cw/cw_strdup.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cw/cw_strdup.c b/src/cw/cw_strdup.c index 2491d676..6a5169bd 100644 --- a/src/cw/cw_strdup.c +++ b/src/cw/cw_strdup.c @@ -1,15 +1,19 @@ #include #include +#include "cw.h" + /** * @brief Duplicate a string * @param s string to duplicate * @return duplicated string, the memory acllocated has to be freed by #free. + * if there was an error allocating the memory, the return value is NULL. */ -char *cw_strdup(const char *s) { - size_t size = strlen(s) + 1; - char *p = malloc(size); - if (p) - memcpy(p, s, size); - return p; +char *cw_strdup(const char *s) +{ + size_t size = strlen(s) + 1; + char *p = malloc(size); + if (p != NULL) + memcpy(p, s, size); + return p; }