[pypy-svn] r51019 - pypy/dist/pypy/rlib
cfbolz at codespeak.net
cfbolz at codespeak.net
Fri Jan 25 11:35:01 CET 2008
Author: cfbolz
Date: Fri Jan 25 11:35:01 2008
New Revision: 51019
Modified:
pypy/dist/pypy/rlib/libffi.py
Log:
set the buffers to NULL after having freed them from the __del__. Add a comment
about why one of the buffer doesn't need to be freed.
Modified: pypy/dist/pypy/rlib/libffi.py
==============================================================================
--- pypy/dist/pypy/rlib/libffi.py (original)
+++ pypy/dist/pypy/rlib/libffi.py Fri Jan 25 11:35:01 2008
@@ -209,8 +209,10 @@
def __del__(self):
if self.ll_cif:
lltype.free(self.ll_cif, flavor='raw')
+ self.ll_cif = lltype.nullptr(FFI_CIFP.TO)
if self.ll_argtypes:
lltype.free(self.ll_argtypes, flavor='raw')
+ self.ll_argtypes = lltype.nullptr(FFI_TYPE_PP.TO)
USERDATA_P = lltype.Ptr(lltype.GcForwardReference())
CALLBACK_TP = lltype.Ptr(lltype.FuncType([rffi.VOIDPP, rffi.VOIDP, USERDATA_P],
@@ -242,6 +244,9 @@
AbstractFuncPtr.__del__(self)
if self.ll_closure:
lltype.free(self.ll_closure, flavor='raw')
+ self.ll_closure = lltype.nullptr(FFI_CLOSUREP.TO)
+ # note that ll_userdata is a GC object and therefore does not need to
+ # be explicitely freed
class RawFuncPtr(AbstractFuncPtr):
@@ -330,8 +335,10 @@
if self.ll_args[i]:
lltype.free(self.ll_args[i], flavor='raw')
lltype.free(self.ll_args, flavor='raw')
+ self.ll_args = lltype.nullptr(rffi.VOIDPP.TO)
if self.ll_result:
lltype.free(self.ll_result, flavor='raw')
+ self.ll_result = lltype.nullptr(rffi.VOIDP.TO)
AbstractFuncPtr.__del__(self)
class CDLL:
@@ -344,8 +351,10 @@
def __del__(self):
if self.lib:
c_dlclose(self.lib)
+ self.lib = lltype.nullptr(rffi.CCHARP.TO)
if self.ll_libname:
lltype.free(self.ll_libname, flavor='raw')
+ self.ll_libname = lltype.nullptr(rffi.CCHARP.TO)
def getpointer(self, name, argtypes, restype):
# these arguments are already casted to proper ffi
More information about the Pypy-commit
mailing list