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

Function build_wide_branch_fn

tests/test_extraction.c:6712–6724  ·  view source on GitHub ↗

C function `wide` whose body holds `n` top-level statements alternating * `if (x) g();` and `while (x) g();`. Caller frees. */

Source from the content-addressed store, hash-verified

6710/* C function `wide` whose body holds `n` top-level statements alternating
6711 * `if (x) g();` and `while (x) g();`. Caller frees. */
6712static char *build_wide_branch_fn(int n) {
6713 size_t cap = (size_t)n * 24 + 64;
6714 char *src = malloc(cap);
6715 if (!src)
6716 return NULL;
6717 size_t pos = (size_t)snprintf(src, cap, "void g(void);\nvoid wide(int x) {\n");
6718 for (int i = 0; i < n; i++) {
6719 pos += (size_t)snprintf(src + pos, cap - pos, "%s",
6720 (i % 2 == 0) ? "if (x) g();\n" : "while (x) g();\n");
6721 }
6722 snprintf(src + pos, cap - pos, "}\n");
6723 return src;
6724}
6725
6726TEST(complexity_wide_body_exceeds_old_stack_cap) {
6727 char *src = build_wide_branch_fn(WIDE_STMTS);

Callers 1

test_extraction.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected