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

Function walk_push_subdir

src/discover/discover.c:1151–1175  ·  view source on GitHub ↗

Push a subdirectory onto the walk stack, inheriting local gitignore * context. Grows the stack geometrically; the caller's `parent` must not * point into the stack array (walk_dir pops into a local copy). */

Source from the content-addressed store, hash-verified

1149 * context. Grows the stack geometrically; the caller's `parent` must not
1150 * point into the stack array (walk_dir pops into a local copy). */
1151static void walk_push_subdir(walk_stack_t *ws, const char *abs_path, const char *rel_path,
1152 const walk_frame_t *parent, bool git_ignored, file_list_t *out) {
1153 if (ws->top >= ws->cap) {
1154 int new_cap = ws->cap * 2;
1155 walk_frame_t *grown = realloc(ws->frames, (size_t)new_cap * sizeof(*grown));
1156 if (!grown) {
1157 out->failed = true;
1158 return;
1159 }
1160 ws->frames = grown;
1161 ws->cap = new_cap;
1162 }
1163 walk_frame_t *slot = &ws->frames[ws->top];
1164 int directory_length = snprintf(slot->dir, CBM_SZ_4K, "%s", abs_path);
1165 int prefix_length = snprintf(slot->prefix, CBM_SZ_4K, "%s", rel_path);
1166 if (directory_length <= 0 || directory_length >= CBM_SZ_4K || prefix_length < 0 ||
1167 prefix_length >= CBM_SZ_4K) {
1168 out->failed = true;
1169 return;
1170 }
1171 slot->ignore_chain = parent->ignore_chain;
1172 slot->sphinx = parent->sphinx;
1173 slot->git_ignored = git_ignored;
1174 ws->top++;
1175}
1176
1177static void walk_dir_process_entry(cbm_dirent_t *entry, const walk_frame_t *frame,
1178 const cbm_discover_opts_t *opts,

Callers 1

walk_dir_process_entryFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected