I'm looking for an efficient way to implement a serialization mechanism in C. I know it would be simple to just store the data in JSON, for example, and then reinitialize everything during the parsing.
But I'm wondering if it is possible (or worth it) to write something that will just take my struct (containing dynamically allocated data), convert all its data and all the pointers into a buffer, so I can place that buffer into a file. Then I would read the file, retrieve the contents, malloc a location of the size of the file contents, and place the contents into that location.
I feel like it is possible to do (convert all the pointers to some kind of local pointing scheme and place all the structures appropriately into a buffer to match those pointers). I'm wondering whether a third party serializer like that exists, or whether it's worth implementing this.