MCPcopy Index your code
hub / github.com/DaveGamble/cJSON / decode_array_index_from_pointer

Function decode_array_index_from_pointer

cJSON_Utils.c:274–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

272}
273
274static cJSON_bool decode_array_index_from_pointer(const unsigned char * const pointer, size_t * const index)
275{
276 size_t parsed_index = 0;
277 size_t position = 0;
278
279 if ((pointer[0] == '0') && ((pointer[1] != '\0') && (pointer[1] != '/')))
280 {
281 /* leading zeroes are not permitted */
282 return 0;
283 }
284
285 for (position = 0; (pointer[position] >= '0') && (pointer[position] <= '9'); position++)
286 {
287 parsed_index = (10 * parsed_index) + (size_t)(pointer[position] - '0');
288
289 }
290
291 if ((pointer[position] != '\0') && (pointer[position] != '/'))
292 {
293 return 0;
294 }
295
296 *index = parsed_index;
297
298 return 1;
299}
300
301static cJSON *get_item_from_pointer(cJSON * const object, const char * pointer, const cJSON_bool case_sensitive)
302{

Callers 3

get_item_from_pointerFunction · 0.85
detach_pathFunction · 0.85
apply_patchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…