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

Function encode_string_as_pointer

cpworker/src/cJSON/cJSON_Utils.c:174–197  ·  view source on GitHub ↗

copy a string while escaping '~' and '/' with ~0 and ~1 JSON pointer escape codes */

Source from the content-addressed store, hash-verified

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)
175{
176 for (; source[0] != '\0'; (void)source++, destination++)
177 {
178 if (source[0] == '/')
179 {
180 destination[0] = '~';
181 destination[1] = '1';
182 destination++;
183 }
184 else if (source[0] == '~')
185 {
186 destination[0] = '~';
187 destination[1] = '0';
188 destination++;
189 }
190 else
191 {
192 destination[0] = source[0];
193 }
194 }
195
196 destination[0] = '\0';
197}
198
199CJSON_PUBLIC(char *) cJSONUtils_FindPointerFromObjectTo(const cJSON *const object, const cJSON *const target)
200{

Callers 3

compose_patchFunction · 0.85
create_patchesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected