@@ -19,8 +19,25 @@ typedef struct {
1919 npy_uintp available ; /* number of cached pointers */
2020 void * ptrs [NCACHE ];
2121} cache_bucket ;
22- static cache_bucket datacache [NBUCKETS ];
23- static cache_bucket dimcache [NBUCKETS_DIM ];
22+
23+ Py_CACHE_ALIGN
24+ Py_TLS static cache_bucket datacache [NBUCKETS ];
25+
26+ Py_CACHE_ALIGN
27+ Py_TLS static cache_bucket dimcache [NBUCKETS_DIM ];
28+
29+ #define malloc PyMem_RawMalloc
30+ #define calloc PyMem_RawCalloc
31+ #define realloc PyMem_RawRealloc
32+ #define free PyMem_RawFree
33+
34+ /*
35+ #define _alignment 16
36+ #define malloc(n) PyMem_RawAlignedMalloc(n, _alignment)
37+ #define calloc(n, e) PyMem_RawAlignedCalloc(n, e, _alignment)
38+ #define realloc(p, n) PyMem_RawAlignedRealloc(p, n, _alignment)
39+ #define free PyMem_RawFree
40+ */
2441
2542/*
2643 * very simplistic small memory block cache to avoid more expensive libc
@@ -151,6 +168,7 @@ PyDataMem_SetEventHook(PyDataMem_EventHookFunc *newhook,
151168{
152169 PyDataMem_EventHookFunc * temp ;
153170 NPY_ALLOW_C_API_DEF
171+ Px_RETURN_NULL ();
154172 NPY_ALLOW_C_API
155173 temp = _PyDataMem_eventhook ;
156174 _PyDataMem_eventhook = newhook ;
@@ -171,6 +189,7 @@ PyDataMem_NEW(size_t size)
171189 void * result ;
172190
173191 result = malloc (size );
192+ Px_RETURN (result );
174193 if (_PyDataMem_eventhook != NULL ) {
175194 NPY_ALLOW_C_API_DEF
176195 NPY_ALLOW_C_API
@@ -192,6 +211,7 @@ PyDataMem_NEW_ZEROED(size_t size, size_t elsize)
192211 void * result ;
193212
194213 result = calloc (size , elsize );
214+ Px_RETURN (result );
195215 if (_PyDataMem_eventhook != NULL ) {
196216 NPY_ALLOW_C_API_DEF
197217 NPY_ALLOW_C_API
@@ -211,6 +231,7 @@ NPY_NO_EXPORT void
211231PyDataMem_FREE (void * ptr )
212232{
213233 free (ptr );
234+ Px_VOID ();
214235 if (_PyDataMem_eventhook != NULL ) {
215236 NPY_ALLOW_C_API_DEF
216237 NPY_ALLOW_C_API
@@ -231,6 +252,7 @@ PyDataMem_RENEW(void *ptr, size_t size)
231252 void * result ;
232253
233254 result = realloc (ptr , size );
255+ Px_RETURN (result );
234256 if (_PyDataMem_eventhook != NULL ) {
235257 NPY_ALLOW_C_API_DEF
236258 NPY_ALLOW_C_API
0 commit comments