Append a single path segment to a mutable buffer that already holds a * normalized slash-separated path. Adds a '/' separator when needed, * returns false if the buffer would overflow. */
| 185 | * normalized slash-separated path. Adds a '/' separator when needed, |
| 186 | * returns false if the buffer would overflow. */ |
| 187 | static bool path_append_segment(char *buf, size_t buf_size, const char *seg, size_t seg_len) { |
| 188 | size_t cur = strlen(buf); |
| 189 | size_t need = cur + (cur > 0 ? FQN_SEP_LEN : 0) + seg_len + FQN_NUL_LEN; |
| 190 | if (need > buf_size) { |
| 191 | return false; |
| 192 | } |
| 193 | if (cur > 0) { |
| 194 | buf[cur++] = '/'; |
| 195 | } |
| 196 | memcpy(buf + cur, seg, seg_len); |
| 197 | buf[cur + seg_len] = '\0'; |
| 198 | return true; |
| 199 | } |
| 200 | |
| 201 | /* Pop the last segment from a mutable slash-separated path. */ |
| 202 | static void path_pop_segment(char *buf) { |
no outgoing calls
no test coverage detected