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

Function pointer_encoded_length

cpworker/src/cJSON/cJSON_Utils.c:158–171  ·  view source on GitHub ↗

calculate the length of a string if encoded as JSON pointer with ~0 and ~1 escape sequences */

Source from the content-addressed store, hash-verified

156
157/* calculate the length of a string if encoded as JSON pointer with ~0 and ~1 escape sequences */
158static size_t pointer_encoded_length(const unsigned char *string)
159{
160 size_t length;
161 for (length = 0; *string != '\0'; (void)string++, length++)
162 {
163 /* character needs to be escaped? */
164 if ((*string == '~') || (*string == '/'))
165 {
166 length++;
167 }
168 }
169
170 return length;
171}
172
173/* copy a string while escaping '~' and '/' with ~0 and ~1 JSON pointer escape codes */
174static void encode_string_as_pointer(unsigned char *destination, const unsigned char *source)

Callers 3

compose_patchFunction · 0.85
create_patchesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected