From eb5000ba61a033c5e6012bc37cef88351560eadb Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Sat, 25 Mar 2017 14:08:58 +0100 Subject: [PATCH] cJSON_strdup: improve readability --- cJSON.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cJSON.c b/cJSON.c index 30ef378..ff584cf 100644 --- a/cJSON.c +++ b/cJSON.c @@ -103,22 +103,22 @@ typedef struct internal_hooks static internal_hooks global_hooks = { malloc, free, realloc }; -static unsigned char* cJSON_strdup(const unsigned char* str, const internal_hooks * const hooks) +static unsigned char* cJSON_strdup(const unsigned char* string, const internal_hooks * const hooks) { - size_t len = 0; + size_t length = 0; unsigned char *copy = NULL; - if (str == NULL) + if (string == NULL) { return NULL; } - len = strlen((const char*)str) + sizeof(""); - if (!(copy = (unsigned char*)hooks->allocate(len))) + length = strlen((const char*)string) + sizeof(""); + if (!(copy = (unsigned char*)hooks->allocate(length))) { return NULL; } - memcpy(copy, str, len); + memcpy(copy, string, length); return copy; } -- GitLab