Skip to content

cbm_store_fetch_call_edges / cbm_leiden / cbm_layout_to_json document caller-owned memory but export no matching free function #1762

Description

@Jumaga2015

What problem does this solve?

I'm compiling codebase-memory-mcp as a DLL to call it from C# (P/Invoke), and three public API functions document caller-owned memory but export no matching free function — unlike the rest of the API:

  • cbm_store_fetch_call_edges (store.h:471) — "caller frees both" — two int64_t* arrays
  • cbm_leiden / cbm_louvain (store.h:843, 847) — "the caller frees it" — one cbm_louvain_result_t* array
  • cbm_layout_to_json (layout3d.h:72) — "Caller must free()." — one char*

The rest of the API does follow a paired-free pattern: cbm_store_find_nodescbm_store_free_nodes, cbm_layout_computecbm_layout_free, cbm_store_get_schemacbm_store_schema_free, etc. From C, a bare free() works fine because of static linking — but from C# there's no way to invoke the DLL's internal free() unless it's exported by name.

Proposed solution

Export a paired free for each of the three, following the existing pattern. I can implement this. Two questions on approach before I send the PR:

  1. 3 specific free functions (cbm_store_free_call_edges, cbm_leiden_free, cbm_layout_free_json), or a generic cbm_free(void*)?
  2. One PR for all 3, or one per function?

Alternatives considered

None that hold up across an FFI boundary — a foreign caller has no way to reach the DLL's internal free() without an exported symbol.

Confirmations

  • I searched existing issues and this is not a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions