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

Function cpp_nest_step

internal/cbm/cpp_branch_views.c:72–98  ·  view source on GitHub ↗

Track one line. Returns the innermost tracked group when the line is one of its #else/#elif lines, else NULL.

Source from the content-addressed store, hash-verified

70// Track one line. Returns the innermost tracked group when the line is one of
71// its #else/#elif lines, else NULL.
72static cpp_frame_t *cpp_nest_step(cpp_nest_t *n, int kind, bool active) {
73 switch (kind) {
74 case CPP_LINE_START:
75 if (n->depth < CPP_NEST_MAX && n->overflow == 0) {
76 n->frames[n->depth++] = (cpp_frame_t){n->next, 0, active};
77 } else {
78 n->overflow++;
79 }
80 n->next++;
81 return NULL;
82 case CPP_LINE_ELSE:
83 if (n->overflow > 0 || n->depth == 0) {
84 return NULL;
85 }
86 n->frames[n->depth - 1].branch++;
87 return &n->frames[n->depth - 1];
88 case CPP_LINE_END:
89 if (n->overflow > 0) {
90 n->overflow--;
91 } else if (n->depth > 0) {
92 n->depth--;
93 }
94 return NULL;
95 default:
96 return NULL;
97 }
98}
99
100// Branch count per group. Returns the group count, or -1 on allocation failure.
101static int cpp_group_branches(CBMArena *a, const char *src, int len, int **out) {

Callers 2

cpp_group_branchesFunction · 0.85
cbm_cpp_branch_viewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected