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

Function print_array

src/cjson.c:1550–1609  ·  view source on GitHub ↗

Render an array to text */

Source from the content-addressed store, hash-verified

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

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…