MCPcopy Create free account
hub / github.com/ading2210/linuxpdf / json_array_set

Function json_array_set

tinyemu/json.c:162–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162int json_array_set(JSONValue val, unsigned int idx, JSONValue prop_val)
163{
164 JSONArray *array;
165 int new_size;
166
167 if (val.type != JSON_ARRAY)
168 return -1;
169 array = val.u.array;
170 if (idx < array->len) {
171 json_free(array->tab[idx]);
172 array->tab[idx] = prop_val;
173 } else if (idx == array->len) {
174 if (array->len >= array->size) {
175 new_size = max_int(array->len + 1, array->size * 3 / 2);
176 array->tab = realloc(array->tab, new_size * sizeof(JSONValue));
177 array->size = new_size;
178 }
179 array->tab[array->len++] = prop_val;
180 } else {
181 return -1;
182 }
183 return 0;
184}
185
186const char *json_get_str(JSONValue val)
187{

Callers 1

json_parse_value2Function · 0.85

Calls 2

json_freeFunction · 0.85
max_intFunction · 0.85

Tested by

no test coverage detected