@@ -1469,7 +1469,7 @@ _ctypes_PyCArrayType_Type_raw_set_impl(CDataObject *self, PyObject *value)
14691469 goto fail ;
14701470 }
14711471
1472- locked_memcpy_to (self , ptr , size );
1472+ memcpy (self -> b_ptr , ptr , size );
14731473
14741474 PyBuffer_Release (& view );
14751475 return 0 ;
@@ -2248,7 +2248,7 @@ static PyObject *CreateSwappedType(ctypes_state *st, PyTypeObject *type,
22482248}
22492249
22502250static PyCArgObject *
2251- PyCSimpleType_paramfunc (ctypes_state * st , CDataObject * self )
2251+ PyCSimpleType_paramfunc_lock_held (ctypes_state * st , CDataObject * self )
22522252{
22532253 const char * fmt ;
22542254 PyCArgObject * parg ;
@@ -2272,10 +2272,20 @@ PyCSimpleType_paramfunc(ctypes_state *st, CDataObject *self)
22722272 parg -> tag = fmt [0 ];
22732273 parg -> pffi_type = fd -> pffi_type ;
22742274 parg -> obj = Py_NewRef (self );
2275- locked_memcpy_from (& parg -> value , self , self -> b_size );
2275+ memcpy (& parg -> value , self -> b_ptr , self -> b_size );
22762276 return parg ;
22772277}
22782278
2279+ static PyCArgObject *
2280+ PyCSimpleType_paramfunc (ctypes_state * st , CDataObject * self )
2281+ {
2282+ PyCArgObject * res ;
2283+ Py_BEGIN_CRITICAL_SECTION (self );
2284+ res = PyCSimpleType_paramfunc_lock_held (st , self );
2285+ Py_END_CRITICAL_SECTION ();
2286+ return res ;
2287+ }
2288+
22792289static int
22802290PyCSimpleType_init (PyObject * self , PyObject * args , PyObject * kwds )
22812291{
@@ -5975,7 +5985,7 @@ cast_check_pointertype(ctypes_state *st, PyObject *arg)
59755985}
59765986
59775987static PyObject *
5978- cast (void * ptr , PyObject * src , PyObject * ctype )
5988+ cast_lock_held (void * ptr , PyObject * src , PyObject * ctype )
59795989{
59805990 PyObject * mod = PyType_GetModuleByDef (Py_TYPE (ctype ), & _ctypesmodule );
59815991 if (!mod ) {
@@ -6030,14 +6040,23 @@ cast(void *ptr, PyObject *src, PyObject *ctype)
60306040 }
60316041 }
60326042 /* Should we assert that result is a pointer type? */
6033- locked_memcpy_to (result , & ptr , sizeof (void * ));
6043+ memcpy (result -> b_ptr , & ptr , sizeof (void * ));
60346044 return (PyObject * )result ;
60356045
60366046 failed :
60376047 Py_DECREF (result );
60386048 return NULL ;
60396049}
60406050
6051+ static PyObject *
6052+ cast (void * ptr , PyObject * src , PyObject * ctype )
6053+ {
6054+ PyObject * res ;
6055+ Py_BEGIN_CRITICAL_SECTION (src );
6056+ res = cast_lock_held (ptr , src , ctype );
6057+ Py_END_CRITICAL_SECTION ();
6058+ return res ;
6059+ }
60416060
60426061static PyObject *
60436062wstring_at (const wchar_t * ptr , int size )
0 commit comments