Skip to content

Consider using ForeignPtr with finalizers for memory managed in C #46

Description

@jorisdral

There are some C objects of which the memory is managed in C. We could use ForeignPtr rather than Ptr internally to emphasise that this memory is foreign-managed. Moreover, we could then attach finalisers to the ForeignPtr to ensure that the foreign-managed memory is freed when the corresponding ForeignPtr is garbage collected.

Example: CXToken structs are allocated by the libclang C library and they should be freed using clang_disposeTokens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageRequires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions