-
Notifications
You must be signed in to change notification settings - Fork 13
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
Clone Context #9
Comments
Contexts cannot currently be cloned. This is a limitation of the underlying GPGme library. As a workaround you can create a new context manually and copy over the necessary attributes for whatever you are trying to do. The errors you are receiving because of a use after free bug: |
@johnschug Thanks for the clarification. So you think the best way is to create a new context and copy over all values? How would I approach this for the things in Also for If I wrote this |
To implement a general clone method you would have to keep track of those changes manually, since the underlying API doesn't provide a way to retrieve that information. For a specific operation you just have to copy over the relevant attributes, e.g. You can find examples of this approach as part of the official C++ Qt bindings: |
Hi @johnschug,
Thank you very much for this great lib!
I'm currently implementing an Elixir NIF (using rustler).
To share the context to Elixir, I implemented a
ResourceArc<ContextNifResource>
.To have immutability in elixir, I want to create a copy of the Context for every function that modifies it. (For example
set_armor
)So that this works, I need the possibility to clone the Context.
I tried to do that myself using this code:
I got those two errors though (not at the same time; randomly):
The text was updated successfully, but these errors were encountered: