libcyaml: Ability to have NULL pointers in arrays of pointers
there are cases that I have fixed-size arrays that always have N pointers, and if any of those is NULL cyaml fails to serialize them.
a use case is I have a mixer that always has N slots, and when the slot is supposed to be empty I simply set array[x] to NULL.
right now I am doing a workaround where I aggregate the non-NULL elements of the array into another array before serializing, and putting them back where they belong after deserializing.
I found this which says that ~ or null can be used for null values
https://stackoverflow.com/a/34089604
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (11 by maintainers)
Okay, thanks, I’ll make tests and do a v1.0.1 in the next few days.
Thanks for the report!
oh sweet, that worked! this is after saving and reloading:
looks fine
You need to set the
CYAML_FLAG_ALLOW_NULL_PTRflag on any values you want to be treated like this.See: https://github.com/tlsa/libcyaml/blob/tlsa/allow-null-pointer-values/include/cyaml/cyaml.h#L137
The documentation above should explain how it behaves.
sure, i’ll try it later today
Interesting. I’ll look into this soon.