MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / th_pad_path_to

Function th_pad_path_to

tests/test_httpd.c:3886–3899  ·  view source on GitHub ↗

Grow path in place to exactly target bytes with 'd' components, none * longer than 200 so every component stays under NAME_MAX. */

Source from the content-addressed store, hash-verified

3884/* Grow path in place to exactly target bytes with 'd' components, none
3885 * longer than 200 so every component stays under NAME_MAX. */
3886static void th_pad_path_to(char *path, size_t cap, int target) {
3887 char fill[201];
3888 memset(fill, 'd', sizeof(fill) - 1);
3889 fill[sizeof(fill) - 1] = '\0';
3890 int n = (int)strlen(path);
3891 while (n < target && (size_t)n + 2 < cap) {
3892 int room = target - n - 1; /* after the '/' */
3893 int len = room > 200 ? 200 : room;
3894 if (len <= 0) {
3895 break;
3896 }
3897 n += snprintf(path + n, cap - (size_t)n, "/%.*s", len, fill);
3898 }
3899}
3900
3901/* Parse an index-status body and compare each entry's "path" with the root
3902 * expected for its slot. Results go to out-params so the caller can tear

Callers 1

test_httpd.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected