MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / print_array

Function print_array

TheForceEngine/TFE_System/cJSON.c:1544–1603  ·  view source on GitHub ↗

Render an array to text */

Source from the content-addressed store, hash-verified

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

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