MCPcopy Create free account
hub / github.com/SVF-tools/SVF / print_array

Function print_array

svf/lib/Util/cJSON.cpp:1543–1602  ·  view source on GitHub ↗

Render an array to text */

Source from the content-addressed store, hash-verified

1541
1542/* Render an array to text */
1543static cJSON_bool print_array(const cJSON * const item, printbuffer * const output_buffer)
1544{
1545 unsigned char *output_pointer = NULL;
1546 size_t length = 0;
1547 cJSON *current_element = item->child;
1548
1549 if (output_buffer == NULL)
1550 {
1551 return false;
1552 }
1553
1554 /* Compose the output array. */
1555 /* opening square bracket */
1556 output_pointer = ensure(output_buffer, 1);
1557 if (output_pointer == NULL)
1558 {
1559 return false;
1560 }
1561
1562 *output_pointer = '[';
1563 output_buffer->offset++;
1564 output_buffer->depth++;
1565
1566 while (current_element != NULL)
1567 {
1568 if (!print_value(current_element, output_buffer))
1569 {
1570 return false;
1571 }
1572 update_offset(output_buffer);
1573 if (current_element->next)
1574 {
1575 length = (size_t) (output_buffer->format ? 2 : 1);
1576 output_pointer = ensure(output_buffer, length + 1);
1577 if (output_pointer == NULL)
1578 {
1579 return false;
1580 }
1581 *output_pointer++ = ',';
1582 if(output_buffer->format)
1583 {
1584 *output_pointer++ = ' ';
1585 }
1586 *output_pointer = '\0';
1587 output_buffer->offset += length;
1588 }
1589 current_element = current_element->next;
1590 }
1591
1592 output_pointer = ensure(output_buffer, 2);
1593 if (output_pointer == NULL)
1594 {
1595 return false;
1596 }
1597 *output_pointer++ = ']';
1598 *output_pointer = '\0';
1599 output_buffer->depth--;
1600

Callers 1

print_valueFunction · 0.85

Calls 3

ensureFunction · 0.85
print_valueFunction · 0.85
update_offsetFunction · 0.85

Tested by

no test coverage detected