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

Function ad_lines

internal/cbm/doc_adoc.c:162–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162static bool ad_lines(ad_doc_t *d, const char *src, int len) {
163 int count = 1;
164 for (int i = 0; i < len; i++) {
165 count += src[i] == '\n';
166 }
167 d->L = (ad_line_t *)cbm_arena_alloc(d->scratch, (size_t)count * sizeof(*d->L));
168 d->in_block = (unsigned char *)cbm_arena_alloc(d->scratch, (size_t)count);
169 if (!d->L || !d->in_block) {
170 return false;
171 }
172 memset(d->in_block, 0, (size_t)count);
173 int pos = 0;
174 for (int i = 0; i < count; i++) {
175 const char *nl = memchr(src + pos, '\n', (size_t)(len - pos));
176 int end = nl ? (int)(nl - src) : len;
177 d->L[i] = (ad_line_t){src + pos, end - pos};
178 pos = end + 1;
179 }
180 d->n = count;
181 return true;
182}
183
184/* Delimited blocks, then the headings outside them. */
185static void ad_structure(ad_doc_t *d) {

Callers 1

Calls 1

cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected