| 1850 | } |
| 1851 | |
| 1852 | static cJSON_bool add_item_to_array(cJSON *array, cJSON *item) |
| 1853 | { |
| 1854 | cJSON *child = NULL; |
| 1855 | |
| 1856 | if ((item == NULL) || (array == NULL)) |
| 1857 | { |
| 1858 | return false; |
| 1859 | } |
| 1860 | |
| 1861 | child = array->child; |
| 1862 | |
| 1863 | if (child == NULL) |
| 1864 | { |
| 1865 | /* list is empty, start new one */ |
| 1866 | array->child = item; |
| 1867 | } |
| 1868 | else |
| 1869 | { |
| 1870 | /* append to the end */ |
| 1871 | while (child->next) |
| 1872 | { |
| 1873 | child = child->next; |
| 1874 | } |
| 1875 | suffix_object(child, item); |
| 1876 | } |
| 1877 | |
| 1878 | return true; |
| 1879 | } |
| 1880 | |
| 1881 | /* Add item to array/object. */ |
| 1882 | CJSON_PUBLIC(void) cJSON_AddItemToArray(cJSON *array, cJSON *item) |
no test coverage detected