Repository navigation
refactor(bindings/c)!: make operation options opaque and owned - #9593
Merged
Merged
Conversation
PsiACE
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #9566.
Rationale for this change
C callers currently allocate option structs and must know their layout. Allocating these structs in the library lets OpenDAL add fields without changing caller allocations. Copying setter inputs also gives callers a clear point at which they can release their buffers.
What changes are included in this PR?
The C header now declares seven incomplete struct types for list, stat, delete, read, reader, write, and copy options. All 56 setter signatures are unchanged. Each operation takes a snapshot of its options. Once the call returns, callers can reuse or free the options handle, including when the returned reader, writer, lister, or copier is still in use.
Are there any user-facing changes?
String and write-metadata setters copy their inputs before returning. Callers can then release or reuse the input buffers. To change an option, call its setter again. Passing
NULLto a string setter clears that option, while""supplies an explicit empty value. PassingNULLfor an operation's options continues to select the defaults.Breaking changes
Affected packages: bindings/c, bindings/go, bindings/zig
Migration:
NULLfor default options. For custom options, replace stack allocation and struct literals withopendal_<operation>_options_new(), configure the handle with setters, and release it withopendal_<operation>_options_free(). The structs are incomplete, so direct field reads, field assignments, andsizeofon the struct no longer compile. Call a setter again if you previously relied on changing its input buffer after the call.opendal.handlibopendal_cfrom the same OpenDAL source version. The new library and earlier development builds both return1fromopendal_c_abi_version(), even though their option layouts differ.OPENDAL_C_LIB_PATHin Go, rebuildlibopendal_cfrom the sources matching the Go binding. The Go wrapper keeps string and metadata buffers alive through each operation for older development libraries that borrow them.AI Usage Statement
magpie/codex/gpt-6.2-astra. Effort:thinking=high. Role: Traced C option ownership, checked binding migration requirements, and identified the ABI 1 development-library compatibility constraint.magpie/codex/gpt-6.2-sol. Effort:thinking=max. Role: Implemented the option handles and caller migration, verified the ABI and binding behavior, and drafted the migration notes.gemini-4-neon. Effort:high. Role: Copy-edited the PR description and migration notes.