MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / cJSON_strndup

Function cJSON_strndup

lib/cJSON.c:170–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170static unsigned char* cJSON_strndup(const unsigned char* str, size_t len) {
171 unsigned char *copy = NULL;
172
173 if (str == NULL)
174 {
175 return NULL;
176 }
177
178 if (!(copy = (unsigned char*)cJSON_malloc(len + 1)))
179 {
180 return NULL;
181 }
182 memcpy(copy, str, len);
183 copy[len] = 0;
184
185 return copy;
186}
187
188void cJSON_InitHooks(cJSON_Hooks* hooks)
189{

Callers 2

_cJSON_AddItemToObjectFunction · 0.85
cJSON_CreateStrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected