diff options
author | Armin Rigo <arigo@tunes.org> | 2018-02-16 09:27:27 +0100 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2018-02-16 09:27:27 +0100 |
commit | 10b51aec2ac55e31a254cec0959bd2ca2659b61a (patch) | |
tree | 5f5820dfc9183d1e3f31912319432ae922e2f77e /cffi/api.py | |
parent | bb2645dbe2c021db1cbfb72fb32e79c0350aa42b (diff) | |
download | cffi-10b51aec2ac55e31a254cec0959bd2ca2659b61a.tar.gz |
Implement ffi.dlclose() for the in-line case
Diffstat (limited to 'cffi/api.py')
-rw-r--r-- | cffi/api.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/cffi/api.py b/cffi/api.py index 446e554..7b63ca7 100644 --- a/cffi/api.py +++ b/cffi/api.py @@ -143,6 +143,13 @@ class FFI(object): self._libraries.append(lib) return lib + def dlclose(self, lib): + """Close a library obtained with ffi.dlopen(). After this call, + access to functions or variables from the library will fail + (possibly with a segmentation fault). + """ + type(lib).__cffi_close__(lib) + def _typeof_locked(self, cdecl): # call me with the lock! key = cdecl @@ -898,6 +905,9 @@ def _make_ffi_library(ffi, libname, flags): return addressof_var(name) raise AttributeError("cffi library has no function or " "global variable named '%s'" % (name,)) + def __cffi_close__(self): + backendlib.close_lib() + self.__dict__.clear() # if libname is not None: try: |