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

Function py_register_lambda

internal/cbm/lsp/py_lsp.c:674–699  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

672/* ── lambda + dict-literal-dispatch registries ────────────────── */
673
674static void py_register_lambda(PyLSPContext *ctx, const char *name, TSNode lambda_node) {
675 if (!ctx || !name)
676 return;
677 if (ctx->lambda_count >= ctx->lambda_cap) {
678 int new_cap = ctx->lambda_cap == 0 ? 8 : ctx->lambda_cap * 2;
679 CBMLambdaEntry *grown =
680 (CBMLambdaEntry *)cbm_arena_alloc(ctx->arena, (size_t)new_cap * sizeof(CBMLambdaEntry));
681 if (!grown)
682 return;
683 if (ctx->lambdas && ctx->lambda_count > 0) {
684 memcpy(grown, ctx->lambdas, (size_t)ctx->lambda_count * sizeof(CBMLambdaEntry));
685 }
686 ctx->lambdas = grown;
687 ctx->lambda_cap = new_cap;
688 }
689 // Overwrite if name already registered.
690 for (int i = 0; i < ctx->lambda_count; i++) {
691 if (ctx->lambdas[i].name && strcmp(ctx->lambdas[i].name, name) == 0) {
692 ctx->lambdas[i].lambda_node = lambda_node;
693 return;
694 }
695 }
696 ctx->lambdas[ctx->lambda_count].name = cbm_arena_strdup(ctx->arena, name);
697 ctx->lambdas[ctx->lambda_count].lambda_node = lambda_node;
698 ctx->lambda_count++;
699}
700
701static TSNode py_lookup_lambda(PyLSPContext *ctx, const char *name) {
702 TSNode null_node = {0};

Callers 1

py_process_statementFunction · 0.85

Calls 2

cbm_arena_allocFunction · 0.50
cbm_arena_strdupFunction · 0.50

Tested by

no test coverage detected