Add an item to an object with constant string as key */
| 1921 | |
| 1922 | /* Add an item to an object with constant string as key */ |
| 1923 | void cJSON_AddItemToObjectCS(cJSON *object, const char *string, cJSON *item) |
| 1924 | { |
| 1925 | if (!item) |
| 1926 | { |
| 1927 | return; |
| 1928 | } |
| 1929 | if (!(item->type & cJSON_StringIsConst) && item->string) |
| 1930 | { |
| 1931 | cJSON_free(item->string); |
| 1932 | } |
| 1933 | #if defined(__GNUC__) && (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || (__GNUC__ > 4) |
| 1934 | _Pragma("GCC diagnostic push") |
| 1935 | _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") |
| 1936 | item->string = (char*)string; |
| 1937 | _Pragma("GCC diagnostic pop") |
| 1938 | #else |
| 1939 | item->string = (char*)string; |
| 1940 | #endif |
| 1941 | item->type |= cJSON_StringIsConst; |
| 1942 | cJSON_AddItemToArray(object, item); |
| 1943 | } |
| 1944 | |
| 1945 | void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) |
| 1946 | { |
no test coverage detected