@@ -125,10 +125,11 @@ _PyObject_ArenaFree(void *ctx, void *ptr, size_t size)
125125
126126#define PYRAW_FUNCS _PyMem_RawMalloc, _PyMem_RawRealloc, _PyMem_RawFree
127127#ifdef WITH_PYMALLOC
128- #define PYOBJECT_FUNCS _PyObject_Malloc, _PyObject_Realloc, _PyObject_Free
128+ # define PYOBJ_FUNCS _PyObject_Malloc, _PyObject_Realloc, _PyObject_Free
129129#else
130- #define PYOBJECT_FUNCS PYRAW_FUNCS
130+ # define PYOBJ_FUNCS PYRAW_FUNCS
131131#endif
132+ #define PYMEM_FUNCS PYRAW_FUNCS
132133
133134#ifdef PYMALLOC_DEBUG
134135typedef struct {
@@ -142,40 +143,41 @@ static struct {
142143 debug_alloc_api_t obj ;
143144} _PyMem_Debug = {
144145 {'r' , {NULL , PYRAW_FUNCS }},
145- {'m' , {NULL , PYRAW_FUNCS }},
146- {'o' , {NULL , PYOBJECT_FUNCS }}
146+ {'m' , {NULL , PYMEM_FUNCS }},
147+ {'o' , {NULL , PYOBJ_FUNCS }}
147148 };
148149
149- #define PYDEBUG_FUNCS _PyMem_DebugMalloc, _PyMem_DebugRealloc, _PyMem_DebugFree
150+ #define PYDBG_FUNCS _PyMem_DebugMalloc, _PyMem_DebugRealloc, _PyMem_DebugFree
150151#endif
151152
152153static PyMemAllocator _PyMem_Raw = {
153154#ifdef PYMALLOC_DEBUG
154- & _PyMem_Debug .raw , PYDEBUG_FUNCS
155+ & _PyMem_Debug .raw , PYDBG_FUNCS
155156#else
156157 NULL, PYRAW_FUNCS
157158#endif
158159 };
159160
160161static PyMemAllocator _PyMem = {
161162#ifdef PYMALLOC_DEBUG
162- & _PyMem_Debug .mem , PYDEBUG_FUNCS
163+ & _PyMem_Debug .mem , PYDBG_FUNCS
163164#else
164- NULL, PYRAW_FUNCS
165+ NULL, PYMEM_FUNCS
165166#endif
166167 };
167168
168169static PyMemAllocator _PyObject = {
169170#ifdef PYMALLOC_DEBUG
170- & _PyMem_Debug .obj , PYDEBUG_FUNCS
171+ & _PyMem_Debug .obj , PYDBG_FUNCS
171172#else
172- NULL, PYOBJECT_FUNCS
173+ NULL, PYOBJ_FUNCS
173174#endif
174175 };
175176
176177#undef PYRAW_FUNCS
177- #undef PYOBJECT_FUNCS
178- #undef PYDEBUG_FUNCS
178+ #undef PYMEM_FUNCS
179+ #undef PYOBJ_FUNCS
180+ #undef PYDBG_FUNCS
179181
180182static PyObjectArenaAllocator _PyObject_Arena = {NULL ,
181183#ifdef MS_WINDOWS
@@ -924,7 +926,7 @@ new_arena(void)
924926 return NULL ; /* overflow */
925927#endif
926928 nbytes = numarenas * sizeof (* arenas );
927- arenaobj = (struct arena_object * )PyMem_Realloc (arenas , nbytes );
929+ arenaobj = (struct arena_object * )PyMem_RawRealloc (arenas , nbytes );
928930 if (arenaobj == NULL )
929931 return NULL ;
930932 arenas = arenaobj ;
@@ -1309,7 +1311,7 @@ _PyObject_Malloc(void *ctx, size_t nbytes)
13091311 * has been reached.
13101312 */
13111313 {
1312- void * result = PyMem_Malloc (nbytes );
1314+ void * result = PyMem_RawMalloc (nbytes );
13131315 if (!result )
13141316 _Py_AllocatedBlocks -- ;
13151317 return result ;
@@ -1539,7 +1541,7 @@ _PyObject_Free(void *ctx, void *p)
15391541redirect :
15401542#endif
15411543 /* We didn't allocate this address. */
1542- PyMem_Free (p );
1544+ PyMem_RawFree (p );
15431545}
15441546
15451547/* realloc. If p is NULL, this acts like malloc(nbytes). Else if nbytes==0,
@@ -1608,14 +1610,14 @@ _PyObject_Realloc(void *ctx, void *p, size_t nbytes)
16081610 * at p. Instead we punt: let C continue to manage this block.
16091611 */
16101612 if (nbytes )
1611- return PyMem_Realloc (p , nbytes );
1613+ return PyMem_RawRealloc (p , nbytes );
16121614 /* C doesn't define the result of realloc(p, 0) (it may or may not
16131615 * return NULL then), but Python's docs promise that nbytes==0 never
16141616 * returns NULL. We don't pass 0 to realloc(), to avoid that endcase
16151617 * to begin with. Even then, we can't be sure that realloc() won't
16161618 * return NULL.
16171619 */
1618- bp = PyMem_Realloc (p , 1 );
1620+ bp = PyMem_RawRealloc (p , 1 );
16191621 return bp ? bp : p ;
16201622}
16211623
0 commit comments