MCPcopy Create free account
hub / github.com/Netis/cloud-probe / print_object

Function print_object

cpworker/src/cJSON/cJSON.c:1732–1843  ·  view source on GitHub ↗

Render an object to text. */

Source from the content-addressed store, hash-verified

1730
1731/* Render an object to text. */
1732static cJSON_bool print_object(const cJSON * const item, printbuffer * const output_buffer)
1733{
1734 unsigned char *output_pointer = NULL;
1735 size_t length = 0;
1736 cJSON *current_item = item->child;
1737
1738 if (output_buffer == NULL)
1739 {
1740 return false;
1741 }
1742
1743 /* Compose the output: */
1744 length = (size_t) (output_buffer->format ? 2 : 1); /* fmt: {\n */
1745 output_pointer = ensure(output_buffer, length + 1);
1746 if (output_pointer == NULL)
1747 {
1748 return false;
1749 }
1750
1751 *output_pointer++ = '{';
1752 output_buffer->depth++;
1753 if (output_buffer->format)
1754 {
1755 *output_pointer++ = '\n';
1756 }
1757 output_buffer->offset += length;
1758
1759 while (current_item)
1760 {
1761 if (output_buffer->format)
1762 {
1763 size_t i;
1764 output_pointer = ensure(output_buffer, output_buffer->depth);
1765 if (output_pointer == NULL)
1766 {
1767 return false;
1768 }
1769 for (i = 0; i < output_buffer->depth; i++)
1770 {
1771 *output_pointer++ = '\t';
1772 }
1773 output_buffer->offset += output_buffer->depth;
1774 }
1775
1776 /* print key */
1777 if (!print_string_ptr((unsigned char*)current_item->string, output_buffer))
1778 {
1779 return false;
1780 }
1781 update_offset(output_buffer);
1782
1783 length = (size_t) (output_buffer->format ? 2 : 1);
1784 output_pointer = ensure(output_buffer, length);
1785 if (output_pointer == NULL)
1786 {
1787 return false;
1788 }
1789 *output_pointer++ = ':';

Callers 1

print_valueFunction · 0.85

Calls 4

ensureFunction · 0.85
print_string_ptrFunction · 0.85
update_offsetFunction · 0.85
print_valueFunction · 0.85

Tested by

no test coverage detected