Skip to content

Add lch_buffer_t type to the C FFI#174

Merged
larsewi merged 2 commits into
masterfrom
add-lch-buffer-type
May 16, 2026
Merged

Add lch_buffer_t type to the C FFI#174
larsewi merged 2 commits into
masterfrom
add-lch-buffer-type

Conversation

@larsewi
Copy link
Copy Markdown
Owner

@larsewi larsewi commented May 16, 2026

Summary

  • Introduce lch_buffer_t { uint8_t *data; size_t len; } in include/leech2.h and use it across the FFI for patch buffers in lch_patch_create, lch_patch_to_sql, lch_patch_inject, and lch_patch_applied. Output buffers are now filled into a caller-owned struct instead of returned via paired uint8_t** / size_t* out-params.
  • Rename lch_patch_free to lch_buffer_free to match the now-generic buffer type. The function also resets data/len after freeing so a double-free is a no-op.
  • Update the C smoke test, man page, and README example to match. The man page entry for lch_patch_inject was also brought in line with the typed-cell API (it still referenced the old value/kind string parameters).

larsewi added 2 commits May 16, 2026 15:20
Introduce an lch_buffer_t struct holding the (uint8_t *data, size_t len)
pair, and use it across the C API for patch buffers. The previous double
pointer + size pair is replaced with a single caller-owned struct that
the library fills in.

Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
The buffer type is now generic (lch_buffer_t), so the free routine
should be too. Update the C header, Rust FFI, C smoke test, man page,
and README example.

Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
@larsewi larsewi added the breaking Incompatible API change label May 16, 2026
@larsewi larsewi merged commit f11c048 into master May 16, 2026
7 checks passed
@larsewi larsewi deleted the add-lch-buffer-type branch May 16, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Incompatible API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant