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

Function encode_string_as_pointer

cJSON_Utils.c:173–196  ·  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

171
172/* copy a string while escaping '~' and '/' with ~0 and ~1 JSON pointer escape codes */
173static void encode_string_as_pointer(unsigned char *destination, const unsigned char *source)
174{
175 for (; source[0] != '\0'; (void)source++, destination++)
176 {
177 if (source[0] == '/')
178 {
179 destination[0] = '~';
180 destination[1] = '1';
181 destination++;
182 }
183 else if (source[0] == '~')
184 {
185 destination[0] = '~';
186 destination[1] = '0';
187 destination++;
188 }
189 else
190 {
191 destination[0] = source[0];
192 }
193 }
194
195 destination[0] = '\0';
196}
197
198CJSON_PUBLIC(char *) cJSONUtils_FindPointerFromObjectTo(const cJSON * const object, const cJSON * const target)
199{

Callers 3

compose_patchFunction · 0.85
create_patchesFunction · 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…