Closed Qqwy closed 1 year ago
Hi @Qqwy, thank you very much for the PR!
I'm still thinking whether there is a nicer approach rather than using unique_ptr with a custom deleted.
Yes, I think that's quite a good idea!
btw the error message in the Linux CI workflow is probably because we didn't include <memory>
(although I'm not 100% sure about it... haven't tried to compile this on my Linux machine).
The idea behind this PR is to manage the setup and cleanup of
NifRes<T>
's automatically, using C++'s builtin scope-based construction/destruction functionality (AKA RAII).This allows us to remove all manual calls to
enif_release_resource
in the code, making it less error-prone to use NifRes/harder to accidentally leak memory.This PR is a work-in-progress. Things that need to happen before merging:
unique_ptr
with a custom deleter.