MCPcopy Create free account
hub / github.com/Netis/cloud-probe / decode_array_index_from_pointer

Function decode_array_index_from_pointer

cpworker/src/cJSON/cJSON_Utils.c:280–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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