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

Function print_value

src/cjson.c:1378–1449  ·  view source on GitHub ↗

Render a value to text. */

Source from the content-addressed store, hash-verified

1376
1377/* Render a value to text. */
1378static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer)
1379{
1380 unsigned char *output = NULL;
1381
1382 if ((item == NULL) || (output_buffer == NULL))
1383 {
1384 return false;
1385 }
1386
1387 switch ((item->type) & 0xFF)
1388 {
1389 case cJSON_NULL:
1390 output = ensure(output_buffer, 5);
1391 if (output == NULL)
1392 {
1393 return false;
1394 }
1395 strcpy((char*)output, "null");
1396 return true;
1397
1398 case cJSON_False:
1399 output = ensure(output_buffer, 6);
1400 if (output == NULL)
1401 {
1402 return false;
1403 }
1404 strcpy((char*)output, "false");
1405 return true;
1406
1407 case cJSON_True:
1408 output = ensure(output_buffer, 5);
1409 if (output == NULL)
1410 {
1411 return false;
1412 }
1413 strcpy((char*)output, "true");
1414 return true;
1415
1416 case cJSON_Number:
1417 return print_number(item, output_buffer);
1418
1419 case cJSON_Raw:
1420 {
1421 size_t raw_length = 0;
1422 if (item->valuestring == NULL)
1423 {
1424 return false;
1425 }
1426
1427 raw_length = strlen(item->valuestring) + sizeof("");
1428 output = ensure(output_buffer, raw_length);
1429 if (output == NULL)
1430 {
1431 return false;
1432 }
1433 memcpy(output, item->valuestring, raw_length);
1434 return true;
1435 }

Callers 5

printFunction · 0.85
cJSON_PrintBufferedFunction · 0.85
cJSON_PrintPreallocatedFunction · 0.85
print_arrayFunction · 0.85
print_objectFunction · 0.85

Calls 5

ensureFunction · 0.85
print_numberFunction · 0.85
print_stringFunction · 0.85
print_arrayFunction · 0.85
print_objectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…