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

Function pod_commands

internal/cbm/extract_defs.c:2417–2447  ·  view source on GitHub ↗

Command paragraphs of one POD block, in order. */

Source from the content-addressed store, hash-verified

2415
2416/* Command paragraphs of one POD block, in order. */
2417static int pod_commands(CBMArena *a, const char *src, uint32_t pb, uint32_t pe, pod_cmd_t **out) {
2418 int cap = DOC_SPAN_INIT_CAP;
2419 int n = 0;
2420 pod_cmd_t *cmds = (pod_cmd_t *)cbm_arena_alloc(a, (size_t)cap * sizeof(pod_cmd_t));
2421 *out = cmds;
2422 if (!cmds) {
2423 return 0;
2424 }
2425 int depth = 0;
2426 uint32_t pos = pb;
2427 uint32_t sb = 0;
2428 uint32_t eb = 0;
2429 while (pod_next_para(src, &pos, pe, &sb, &eb)) {
2430 if (src[sb] != '=' || sb + SKIP_ONE >= eb || !isalpha((unsigned char)src[sb + SKIP_ONE])) {
2431 continue;
2432 }
2433 if (n == cap) {
2434 int ncap = cap * DOC_SPAN_GROW;
2435 pod_cmd_t *grown = (pod_cmd_t *)cbm_arena_alloc(a, (size_t)ncap * sizeof(pod_cmd_t));
2436 if (!grown) {
2437 break;
2438 }
2439 memcpy(grown, cmds, (size_t)n * sizeof(pod_cmd_t));
2440 cmds = grown;
2441 cap = ncap;
2442 *out = cmds;
2443 }
2444 cmds[n++] = pod_classify(src, sb, eb, &depth);
2445 }
2446 return n;
2447}
2448
2449/* End byte of the section that cmds[ci] (a =head or =item) opens. */
2450static uint32_t pod_section_end(const pod_cmd_t *cmds, int n, int ci, uint32_t pe) {

Callers 1

pod_index_blockFunction · 0.85

Calls 3

pod_next_paraFunction · 0.85
pod_classifyFunction · 0.85
cbm_arena_allocFunction · 0.70

Tested by

no test coverage detected