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

Function c_doc_lines

internal/cbm/doclink_c.c:113–138  ·  view source on GitHub ↗

The doc's lines without their comment marks. */

Source from the content-addressed store, hash-verified

111
112/* The doc's lines without their comment marks. */
113static int c_doc_lines(CBMArena *a, const char *doc, uint32_t doc_line, c_line_t **out) {
114 int cap = SKIP_ONE;
115 for (const char *p = doc; *p; p++) {
116 cap += *p == '\n';
117 }
118 c_line_t *lines = (c_line_t *)cbm_arena_alloc(a, (size_t)cap * sizeof(c_line_t));
119 if (!lines) {
120 return 0;
121 }
122 int n = 0;
123 bool block = false;
124 for (const char *p = doc; n < cap;) {
125 const char *le = strchr(p, '\n');
126 if (!le) {
127 le = p + strlen(p);
128 }
129 lines[n] = c_strip_line(p, le, n == 0, &block, doc_line + (uint32_t)n);
130 n++;
131 if (!*le) {
132 break;
133 }
134 p = le + SKIP_ONE;
135 }
136 *out = lines;
137 return n;
138}
139
140/* ── Tokens ──────────────────────────────────────────────────────── */
141

Callers 1

c_harvestFunction · 0.85

Calls 2

c_strip_lineFunction · 0.85
cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected