3 ms·
"I would move json_*_t structs to the header file and eliminate a bunch of API functions that service the access to these structs. It's a C library after all, e
by cmccabe 14y ago
"I would move json_*_t structs to the header file and eliminate a bunch of API functions that service the access to these structs. It's a C library after all, everyone knows how to shoot one's own leg."
I strongly disagree. The author did exactly the right thing by hiding the internal data representation behind accessor functions. This makes it easy for him to change the internal data representation in the future without breaking binary compatibility.
See the libabc REAME for a fuller explanation:
https://git.kernel.org/?p=linux/kernel/git/kay/libabc.git;a=blob_plain;f=README https://git.kernel.org/?p=linux/kernel/git/kay/libabc.git;a=...
Summary: "Do not expose any complex structures in your API"
Unrelated: please don't be one of those people who typedef every struct. It's really ugly and obfuscatory (see Linus' remarks on this).
- deleted 14y ago[deleted]