MCPcopy Create free account
hub / github.com/OpenIPC/firmware / cJSON_GetArraySize

Function cJSON_GetArraySize

general/package/xmdp/src/cjson/cJSON.c:1822–1843  ·  view source on GitHub ↗

Get Array size/item / object item. */

Source from the content-addressed store, hash-verified

1820
1821/* Get Array size/item / object item. */
1822CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array)
1823{
1824 cJSON *child = NULL;
1825 size_t size = 0;
1826
1827 if (array == NULL)
1828 {
1829 return 0;
1830 }
1831
1832 child = array->child;
1833
1834 while(child != NULL)
1835 {
1836 size++;
1837 child = child->next;
1838 }
1839
1840 /* FIXME: Can overflow here. Cannot be fixed without breaking the API */
1841
1842 return (int)size;
1843}
1844
1845static cJSON* get_array_item(const cJSON *array, size_t index)
1846{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected