MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / encode_string_as_pointer

Function encode_string_as_pointer

ThirdParty/cjson/cJSON_Utils.c:162–184  ·  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

160
161/* copy a string while escaping '~' and '/' with ~0 and ~1 JSON pointer escape codes */
162static void encode_string_as_pointer(unsigned char *destination, const unsigned char *source)
163{
164 for (; source[0] != '\0'; (void)source++, destination++)
165 {
166 if (source[0] == '/')
167 {
168 destination[1] = '1';
169 destination++;
170 }
171 else if (source[0] == '~')
172 {
173 destination[0] = '~';
174 destination[1] = '1';
175 destination++;
176 }
177 else
178 {
179 destination[0] = source[0];
180 }
181 }
182
183 destination[0] = '\0';
184}
185
186CJSON_PUBLIC(char *) cJSONUtils_FindPointerFromObjectTo(const cJSON * const object, const cJSON * const target)
187{

Callers 3

compose_patchFunction · 0.85
create_patchesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected