diff options
author | Lucia Li <luciali@google.com> | 2021-11-08 21:45:14 +0800 |
---|---|---|
committer | Lucia Li <luciali@google.com> | 2021-11-09 11:01:46 +0800 |
commit | 6aa63b08263172a979012747497f4207cc341bb0 (patch) | |
tree | 64f8c90740adbe25c30379d6567fd2acafcbd2dd /c/lib_obj.c | |
parent | 3e013ad5e4325c9a301ddde47e997bfd797167cd (diff) | |
download | cffi-6aa63b08263172a979012747497f4207cc341bb0.tar.gz |
Upgrade cffi from 1.12.2 to 1.15.0
Source is fetched from
https://foss.heptapod.net/pypy/cffi/-/archive/branch/release-1.15/cffi-branch-release-1.15.zip
Build cffi manually and update Android.bp
Bug: 205265538
Test: None
Change-Id: I91a5ed3b96029b3988602aba6a00c0e0748d0600
Diffstat (limited to 'c/lib_obj.c')
-rw-r--r-- | c/lib_obj.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/c/lib_obj.c b/c/lib_obj.c index 7cd40ec..38bf3d5 100644 --- a/c/lib_obj.c +++ b/c/lib_obj.c @@ -29,6 +29,7 @@ struct LibObject_s { PyObject *l_libname; /* some string that gives the name of the lib */ FFIObject *l_ffi; /* reference back to the ffi object */ void *l_libhandle; /* the dlopen()ed handle, if any */ + int l_auto_close; /* if we must dlclose() this handle */ }; static struct CPyExtFunc_s *_cpyextfunc_get(PyObject *x) @@ -91,7 +92,8 @@ static void *cdlopen_fetch(PyObject *libname, void *libhandle, static void lib_dealloc(LibObject *lib) { PyObject_GC_UnTrack(lib); - cdlopen_close_ignore_errors(lib->l_libhandle); + if (lib->l_auto_close) + cdlopen_close_ignore_errors(lib->l_libhandle); Py_DECREF(lib->l_dict); Py_DECREF(lib->l_libname); Py_DECREF(lib->l_ffi); @@ -587,7 +589,7 @@ static PyMethodDef lib_methods[] = { static PyTypeObject Lib_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "CompiledLib", + "_cffi_backend.Lib", sizeof(LibObject), 0, (destructor)lib_dealloc, /* tp_dealloc */ @@ -624,7 +626,7 @@ static PyTypeObject Lib_Type = { }; static LibObject *lib_internal_new(FFIObject *ffi, const char *module_name, - void *dlopen_libhandle) + void *dlopen_libhandle, int auto_close) { LibObject *lib; PyObject *libname, *dict; @@ -647,6 +649,7 @@ static LibObject *lib_internal_new(FFIObject *ffi, const char *module_name, Py_INCREF(ffi); lib->l_ffi = ffi; lib->l_libhandle = dlopen_libhandle; + lib->l_auto_close = auto_close; return lib; err3: @@ -654,7 +657,8 @@ static LibObject *lib_internal_new(FFIObject *ffi, const char *module_name, err2: Py_DECREF(libname); err1: - cdlopen_close_ignore_errors(dlopen_libhandle); + if (auto_close) + cdlopen_close_ignore_errors(dlopen_libhandle); return NULL; } |