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

Function parse_object

external/cJSON/cJSON.c:1662–1777  ·  view source on GitHub ↗

Build an object from the text. */

Source from the content-addressed store, hash-verified

1660
1661/* Build an object from the text. */
1662static cJSON_bool parse_object(cJSON * const item, parse_buffer * const input_buffer)
1663{
1664 cJSON *head = NULL; /* linked list head */
1665 cJSON *current_item = NULL;
1666
1667 if (input_buffer->depth >= CJSON_NESTING_LIMIT)
1668 {
1669 return false; /* to deeply nested */
1670 }
1671 input_buffer->depth++;
1672
1673 if (cannot_access_at_index(input_buffer, 0) || (buffer_at_offset(input_buffer)[0] != '{'))
1674 {
1675 goto fail; /* not an object */
1676 }
1677
1678 input_buffer->offset++;
1679 buffer_skip_whitespace(input_buffer);
1680 if (can_access_at_index(input_buffer, 0) && (buffer_at_offset(input_buffer)[0] == '}'))
1681 {
1682 goto success; /* empty object */
1683 }
1684
1685 /* check if we skipped to the end of the buffer */
1686 if (cannot_access_at_index(input_buffer, 0))
1687 {
1688 input_buffer->offset--;
1689 goto fail;
1690 }
1691
1692 /* step back to character in front of the first element */
1693 input_buffer->offset--;
1694 /* loop through the comma separated array elements */
1695 do
1696 {
1697 /* allocate next item */
1698 cJSON *new_item = cJSON_New_Item(&(input_buffer->hooks));
1699 if (new_item == NULL)
1700 {
1701 goto fail; /* allocation failure */
1702 }
1703
1704 /* attach next item to list */
1705 if (head == NULL)
1706 {
1707 /* start the linked list */
1708 current_item = head = new_item;
1709 }
1710 else
1711 {
1712 /* add to the end and advance */
1713 current_item->next = new_item;
1714 new_item->prev = current_item;
1715 current_item = new_item;
1716 }
1717
1718 if (cannot_access_at_index(input_buffer, 1))
1719 {

Callers 1

parse_valueFunction · 0.85

Calls 5

buffer_skip_whitespaceFunction · 0.85
cJSON_New_ItemFunction · 0.85
parse_valueFunction · 0.85
cJSON_DeleteFunction · 0.85
parse_stringFunction · 0.70

Tested by

no test coverage detected