MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / print_value

Function print_value

external/cJSON/cJSON.c:1423–1494  ·  view source on GitHub ↗

Render a value to text. */

Source from the content-addressed store, hash-verified

1421
1422/* Render a value to text. */
1423static cJSON_bool print_value(const cJSON * const item, printbuffer * const output_buffer)
1424{
1425 unsigned char *output = NULL;
1426
1427 if ((item == NULL) || (output_buffer == NULL))
1428 {
1429 return false;
1430 }
1431
1432 switch ((item->type) & 0xFF)
1433 {
1434 case cJSON_NULL:
1435 output = ensure(output_buffer, 5);
1436 if (output == NULL)
1437 {
1438 return false;
1439 }
1440 strcpy((char*)output, "null");
1441 return true;
1442
1443 case cJSON_False:
1444 output = ensure(output_buffer, 6);
1445 if (output == NULL)
1446 {
1447 return false;
1448 }
1449 strcpy((char*)output, "false");
1450 return true;
1451
1452 case cJSON_True:
1453 output = ensure(output_buffer, 5);
1454 if (output == NULL)
1455 {
1456 return false;
1457 }
1458 strcpy((char*)output, "true");
1459 return true;
1460
1461 case cJSON_Number:
1462 return print_number(item, output_buffer);
1463
1464 case cJSON_Raw:
1465 {
1466 size_t raw_length = 0;
1467 if (item->valuestring == NULL)
1468 {
1469 return false;
1470 }
1471
1472 raw_length = strlen(item->valuestring) + sizeof("");
1473 output = ensure(output_buffer, raw_length);
1474 if (output == NULL)
1475 {
1476 return false;
1477 }
1478 memcpy(output, item->valuestring, raw_length);
1479 return true;
1480 }

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