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

Function ti_split_lines

src/mcp/test_impact_source.c:471–489  ·  view source on GitHub ↗

Lines as the reference splits them (`text.split('\n')`): a final newline * leaves one more, empty line. */

Source from the content-addressed store, hash-verified

469/* Lines as the reference splits them (`text.split('\n')`): a final newline
470 * leaves one more, empty line. */
471static bool ti_split_lines(ti_file_t *f) {
472 int count = 1;
473 for (size_t i = 0; i < f->len; i++) {
474 count += f->text[i] == '\n';
475 }
476 f->line_starts = cbm_alloc(CBM_MEM_CLASS_EXTRACT, (size_t)count * sizeof(size_t));
477 if (!f->line_starts) {
478 return false;
479 }
480 int at = 0;
481 f->line_starts[at++] = 0;
482 for (size_t i = 0; i < f->len; i++) {
483 if (f->text[i] == '\n') {
484 f->line_starts[at++] = i + 1;
485 }
486 }
487 f->line_count = count;
488 return true;
489}
490
491static int ti_path_compare(const void *left, const void *right) {
492 return strcmp(((const ti_file_t *)left)->path, ((const ti_file_t *)right)->path);

Callers 1

cbm_ti_source_finishFunction · 0.85

Calls 1

cbm_allocFunction · 0.85

Tested by

no test coverage detected