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. */
| 210 | * normalized slash-separated path. Adds a '/' separator when needed, |
| 211 | * returns false if the buffer would overflow. */ |
| 212 | static bool path_append_segment(char *buf, size_t buf_size, const char *seg, size_t seg_len) { |
| 213 | size_t cur = strlen(buf); |
| 214 | size_t need = cur + (cur > 0 ? FQN_SEP_LEN : 0) + seg_len + FQN_NUL_LEN; |
| 215 | if (need > buf_size) { |
| 216 | return false; |
| 217 | } |
| 218 | if (cur > 0) { |
| 219 | buf[cur++] = '/'; |
| 220 | } |
| 221 | memcpy(buf + cur, seg, seg_len); |
| 222 | buf[cur + seg_len] = '\0'; |
| 223 | return true; |
| 224 | } |
| 225 | |
| 226 | /* Pop the last segment from a mutable slash-separated path. */ |
| 227 | static void path_pop_segment(char *buf) { |
no outgoing calls
no test coverage detected