getty-zig / getty

A (de)serialization framework for Zig
https://getty.so
MIT License
183 stars 14 forks source link

Add `isVariantAllocated` method to `UnionAccess` #114

Closed ibokuri closed 1 year ago

ibokuri commented 1 year ago

Problem

UnionAccess implementations leak memory if they heap-allocate their variants. This is because the visitors that call variantSeed have no way of knowing whether or not the variant was allocated.

Proposal

Just like with MapAccess's isKeyAllocated method, UnionAccess should be updated to have a isVariantAccess method, so that visitors can find out if a variant was allocated on the heap.

Alternatives

No response

Additional Context

No response