-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A number of FFI functions return strings that are owned by the library and must be freed manually. Unfortunately, returning a `str` from a function would result in a memory leak, as the Python runtime would not know to free the string. This commit adds an `OwnedString` class that wraps a `str` and a function that frees the string. The `__del__` method of the class calls the free function, ensuring that the string is freed when the object is garbage collected. Signed-off-by: JP-Ellis <[email protected]>
- Loading branch information
Showing
2 changed files
with
104 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters