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

Function pr_sub_node

src/pipeline/doc_links_perl.c:326–344  ·  view source on GitHub ↗

The node of sub `name` of file f; NULL when it has none of its own. */

Source from the content-addressed store, hash-verified

324
325/* The node of sub `name` of file f; NULL when it has none of its own. */
326static const cbm_gbuf_node_t *pr_sub_node(const pr_ctx_t *c, const pr_file_t *f, const char *name) {
327 size_t ql = strlen(f->module_qn);
328 size_t nl = strlen(name);
329 char stack[CBM_SZ_512];
330 char *qn = ql + nl + PAIR_LEN <= sizeof(stack)
331 ? stack
332 : (char *)cbm_alloc(CBM_MEM_CLASS_OTHER, ql + nl + PAIR_LEN);
333 if (!qn) {
334 return NULL;
335 }
336 memcpy(qn, f->module_qn, ql);
337 qn[ql] = '.';
338 memcpy(qn + ql + SKIP_ONE, name, nl + SKIP_ONE);
339 const cbm_gbuf_node_t *n = cbm_gbuf_find_by_qn(c->g, qn);
340 if (qn != stack) {
341 cbm_free(CBM_MEM_CLASS_OTHER, qn);
342 }
343 return (pr_node_is(n, f, "Function") || pr_node_is(n, f, "Method")) ? n : NULL;
344}
345
346static bool pr_has_sub(const pr_file_t *f, const char *name) {
347 for (int i = 0; i < f->nsubs; i++) {

Callers 1

pr_sectionFunction · 0.85

Calls 4

cbm_allocFunction · 0.85
cbm_gbuf_find_by_qnFunction · 0.85
cbm_freeFunction · 0.85
pr_node_isFunction · 0.85

Tested by

no test coverage detected