-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Passing a bitsery buffer to a C API #71
Comments
Right, but that example is for a C static array and for the other one, I don't know the total size of the serialized data that will be saved ahead of time. For example, a possible solution would be to give bitsery a Hopefully I explained the problem more clearly now. |
You left with only one solution then. You will need to provide a custom buffer implementation and specialize it for |
Ok I see, thank you. |
I want to pass some serialized state to a C API, but I don't really see a way of doing that without an additional copy.
By "additional copy" I mean, currently I am using a
std::vector
BufferWriter
. Thestd::vector
will be destroyed after my C API call returns because of RAII. I can't stop that. So I have to usemalloc
+ copy that data somewhere else, which is wasteful.To be clear, I am the developer of that C API. I want to expose "load" and "save" functions for some state.
So perhaps I could use an opaque pointer that holds a
new
edstd::vector
? But that sounds hacky.Maybe there's a solution where
OutputBufferAdapter
can be implemented to usemalloc
+realloc
.Excuse my quick + maybe unclear problem description.
Also if this is not currently feasible, I understand.
Thanks.
The text was updated successfully, but these errors were encountered: