getty-zig / getty

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

Move logic in `getty.de.free` into Deserialization Blocks #106

Closed ibokuri closed 1 year ago

ibokuri commented 1 year ago

Problem

Having a single function for freeing every single type that Getty supports isn't scalable, is a pain to maintain, and doesn't work well with things like attributes.

free's demise was always inevitable and now the day of reckoning has come!

Proposal

First, the logic in getty.de.free will be moved into a relevant Deserialization Block, which will now allowed to define an optional function (called free) for freeing resources.

Then, getty.de.free will be updated to simply walk through user DBs, type-defined DBs, serializer DBs, and getty.default_dt to find which free function to call.

Alternatives

No response

Additional Context

No response