Skip to content

Add asdf_free() for buffers the library allocates for the caller - #253

Open
cruzzil wants to merge 1 commit into
asdf-format:mainfrom
cruzzil:asdf-free
Open

Add asdf_free() for buffers the library allocates for the caller#253
cruzzil wants to merge 1 commit into
asdf-format:mainfrom
cruzzil:asdf-free

Conversation

@cruzzil

@cruzzil cruzzil commented Sep 5, 2026

Copy link
Copy Markdown

Fixes #250.

asdf_write_to_mem, asdf_ndarray_read_all, asdf_ndarray_read_tile_ndim and
asdf_ndarray_read_tile_2d hand the caller a buffer and document free() as
the way to release it, which makes the allocator part of the ABI: it is
undefined behaviour across a DLL boundary where the library and the application
link different C runtimes with separate heaps, and it prevents these functions
from ever allocating differently.

This adds asdf_free() in asdf/util.h (the one header every other public
header already includes) and updates the four doc comments, the ndarray/writing
usage docs and the affected tests to use it.

The implementation is just free(), so this is source-compatible: existing
callers keep working unchanged.

asdf_write_to_mem, asdf_ndarray_read_all and the asdf_ndarray_read_tile_*
family hand the caller a buffer and documented free() as the way to release
it, which makes the allocator part of the ABI.  Export asdf_free() and point
those docs at it instead; it is currently just free(), so existing callers
keep working.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider an asdf_free() for buffers the library allocates on the caller's behalf

1 participant