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

Function gi_add_pattern

src/discover/gitignore.c:36–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34/* ── Pattern parsing ─────────────────────────────────────────────── */
35
36static void gi_add_pattern(cbm_gitignore_t *gi, const char *line, int len) {
37 gi_view_t view;
38 if (!gi_normalize(line, (size_t)len, &view, NULL) || !view.length) {
39 return;
40 }
41 gi_pattern_t p = {.negated = view.negated, .dir_only = view.dir_only, .rooted = view.rooted};
42 const char *start = view.text;
43 len = (int)view.length;
44
45 /* Copy pattern */
46 p.pattern = malloc(len + SKIP_ONE);
47 if (!p.pattern) {
48 return;
49 }
50 memcpy(p.pattern, start, len);
51 p.pattern[len] = '\0';
52
53 /* Grow array if needed */
54 if (gi->count >= gi->capacity) {
55 int new_cap = gi->capacity ? gi->capacity * PAIR_LEN : GI_INIT_CAP;
56 gi_pattern_t *new_patterns = realloc(gi->patterns, new_cap * sizeof(gi_pattern_t));
57 if (!new_patterns) {
58 free(p.pattern);
59 return;
60 }
61 gi->patterns = new_patterns;
62 gi->capacity = new_cap;
63 }
64
65 gi->patterns[gi->count++] = p;
66}
67
68/* ── Public API ──────────────────────────────────────────────────── */
69

Callers 1

cbm_gitignore_parseFunction · 0.85

Calls 1

gi_normalizeFunction · 0.85

Tested by

no test coverage detected