MCPcopy Create free account
hub / github.com/esnet/iperf / cJSON_SetValuestring

Function cJSON_SetValuestring

src/cjson.c:411–436  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411CJSON_PUBLIC(char*) cJSON_SetValuestring(cJSON *object, const char *valuestring)
412{
413 char *copy = NULL;
414 /* if object's type is not cJSON_String or is cJSON_IsReference, it should not set valuestring */
415 if (!(object->type & cJSON_String) || (object->type & cJSON_IsReference))
416 {
417 return NULL;
418 }
419 if (strlen(valuestring) <= strlen(object->valuestring))
420 {
421 strcpy(object->valuestring, valuestring);
422 return object->valuestring;
423 }
424 copy = (char*) cJSON_strdup((const unsigned char*)valuestring, &global_hooks);
425 if (copy == NULL)
426 {
427 return NULL;
428 }
429 if (object->valuestring != NULL)
430 {
431 cJSON_free(object->valuestring);
432 }
433 object->valuestring = copy;
434
435 return copy;
436}
437
438typedef struct
439{

Callers

nothing calls this directly

Calls 2

cJSON_strdupFunction · 0.85
cJSON_freeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…