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

Function cx_build_pyext

tests/test_complexity.c:348–381  ·  view source on GitHub ↗

Every file probes absent external submodules and retains a real local-call * control. Independent module copies grow the shared registry without adding * cross-copy dependencies. Both sizes exceed the parallel-driver threshold. */

Source from the content-addressed store, hash-verified

346 * control. Independent module copies grow the shared registry without adding
347 * cross-copy dependencies. Both sizes exceed the parallel-driver threshold. */
348static int cx_build_pyext(const char *root, int k) {
349 char dir[1024];
350 char path[1200];
351 for (int m = 0; m < k; m++) {
352 int n = snprintf(dir, sizeof(dir), "%s/pyext/mod%d", root, m);
353 if (n < 0 || (size_t)n >= sizeof(dir) || th_mkdir_p(dir) != 0)
354 return -1;
355 for (int j = 0; j < CX_PYEXT_FILES_PER_MOD; j++) {
356 n = snprintf(path, sizeof(path), "%s/p%d.py", dir, j);
357 if (n < 0 || (size_t)n >= sizeof(path))
358 return -1;
359 FILE *f = fopen(path, "w");
360 if (!f)
361 return -1;
362 bool written = fprintf(f, "import extlib\n\n") >= 0;
363 for (int d = 0; written && d < CX_PYEXT_DEFS_PER_FILE; d++) {
364 written =
365 fprintf(f, "def cx_pyext_definition_%d(x):\n return x + %d\n\n", d, d) >= 0;
366 }
367 if (written)
368 written =
369 fprintf(f, "def cx_pyext_use():\n return (cx_pyext_definition_0(0)") >= 0;
370 for (int probe = 0; written && probe < CX_PYEXT_PROBES_PER_FILE; probe++) {
371 written = fprintf(f, " + extlib.sub%d.helper(%d)", probe, probe) >= 0;
372 }
373 if (written)
374 written = fprintf(f, ")\n") >= 0;
375 int closed = fclose(f);
376 if (!written || closed != 0)
377 return -1;
378 }
379 }
380 return 0;
381}
382
383/* ── Metrics ─────────────────────────────────────────────────────────── */
384

Callers

nothing calls this directly

Calls 2

th_mkdir_pFunction · 0.85
fopenFunction · 0.85

Tested by

no test coverage detected