@@ -197,6 +197,24 @@ arraydata_set_items(arraydata *data, char *newitems, Py_ssize_t newsize, int ite
197197 return data ;
198198}
199199
200+ #ifndef Py_GIL_DISABLED
201+
202+ static arraydata *
203+ arraydata_realloc (arraydata * data , Py_ssize_t size , int itemsize )
204+ {
205+ if (size > PY_SSIZE_T_MAX /itemsize - 1 ) {
206+ return NULL ;
207+ }
208+ data = (arraydata * )PyMem_Realloc (data , sizeof (arraydata ) + size * itemsize );
209+ if (data == NULL ) {
210+ return NULL ;
211+ }
212+ data -> allocated = size ;
213+ return data ;
214+ }
215+
216+ #endif
217+
200218#ifdef Py_GIL_DISABLED
201219
202220static void
@@ -205,25 +223,25 @@ atomic_itemcpy(void *dest, const void *src, size_t n, int itemsize)
205223 if (itemsize == 1 ) {
206224 for (char * d = (char * ) dest , * end = d + n , * s = (char * ) src ;
207225 d < end ; d ++ , s ++ ) {
208- _Py_atomic_store_char_relaxed ( d , _Py_atomic_load_char_relaxed (s ) );
226+ * d = _Py_atomic_load_char_relaxed (s );
209227 }
210228 }
211229 else if (itemsize == 2 ) {
212230 for (short * d = (short * ) dest , * end = d + n , * s = (short * ) src ;
213231 d < end ; d ++ , s ++ ) {
214- _Py_atomic_store_short_relaxed ( d , _Py_atomic_load_short_relaxed (s ) );
232+ * d = _Py_atomic_load_short_relaxed (s );
215233 }
216234 }
217235 else if (itemsize == 4 ) {
218236 for (PY_UINT32_T * d = (PY_UINT32_T * ) dest , * end = d + n , * s = (PY_UINT32_T * ) src ;
219237 d < end ; d ++ , s ++ ) {
220- _Py_atomic_store_uint32_relaxed ( d , _Py_atomic_load_uint32_relaxed (s ) );
238+ * d = ( PY_UINT32_T ) _Py_atomic_load_uint32_relaxed (s );
221239 }
222240 }
223241 else if (itemsize == 8 ) {
224242 for (PY_UINT64_T * d = (PY_UINT64_T * ) dest , * end = d + n , * s = (PY_UINT64_T * ) src ;
225243 d < end ; d ++ , s ++ ) {
226- _Py_atomic_store_uint64_relaxed ( d , _Py_atomic_load_uint64_relaxed (s ) );
244+ * d = ( PY_UINT64_T ) _Py_atomic_load_uint64_relaxed (s );
227245 }
228246 }
229247 else {
@@ -233,24 +251,6 @@ atomic_itemcpy(void *dest, const void *src, size_t n, int itemsize)
233251
234252#endif
235253
236- #ifndef Py_GIL_DISABLED
237-
238- static arraydata *
239- arraydata_realloc (arraydata * data , Py_ssize_t size , int itemsize )
240- {
241- if (size > PY_SSIZE_T_MAX /itemsize - 1 ) {
242- return NULL ;
243- }
244- data = (arraydata * )PyMem_Realloc (data , sizeof (arraydata ) + size * itemsize );
245- if (data == NULL ) {
246- return NULL ;
247- }
248- data -> allocated = size ;
249- return data ;
250- }
251-
252- #endif
253-
254254static int
255255array_resize (arrayobject * self , Py_ssize_t newsize )
256256{
0 commit comments