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