summaryrefslogtreecommitdiffstats
path: root/Python/pyarena.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-07 15:18:53 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-07 15:18:53 (GMT)
commitc6632e7eb49da96d4e6914b2543421206a937039 (patch)
tree3b5d4cc2c66fd7cff0b53cc1a9f761f1f832c01f /Python/pyarena.c
parent80aa565fb4a4be45ea7b94487bd10f1ab0ff5410 (diff)
downloadcpython-c6632e7eb49da96d4e6914b2543421206a937039.zip
cpython-c6632e7eb49da96d4e6914b2543421206a937039.tar.gz
cpython-c6632e7eb49da96d4e6914b2543421206a937039.tar.bz2
Issue #18203: Replace malloc() with PyMem_Malloc() to allocate arena objects
Diffstat (limited to 'Python/pyarena.c')
-rw-r--r--Python/pyarena.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Python/pyarena.c b/Python/pyarena.c
index 02a31d8..103603f 100644
--- a/Python/pyarena.c
+++ b/Python/pyarena.c
@@ -77,7 +77,7 @@ block_new(size_t size)
{
/* Allocate header and block as one unit.
ab_mem points just past header. */
- block *b = (block *)malloc(sizeof(block) + size);
+ block *b = (block *)PyMem_Malloc(sizeof(block) + size);
if (!b)
return NULL;
b->ab_size = size;
@@ -92,7 +92,7 @@ static void
block_free(block *b) {
while (b) {
block *next = b->ab_next;
- free(b);
+ PyMem_Free(b);
b = next;
}
}
@@ -127,20 +127,20 @@ block_alloc(block *b, size_t size)
PyArena *
PyArena_New()
{
- PyArena* arena = (PyArena *)malloc(sizeof(PyArena));
+ PyArena* arena = (PyArena *)PyMem_Malloc(sizeof(PyArena));
if (!arena)
return (PyArena*)PyErr_NoMemory();
arena->a_head = block_new(DEFAULT_BLOCK_SIZE);
arena->a_cur = arena->a_head;
if (!arena->a_head) {
- free((void *)arena);
+ PyMem_Free((void *)arena);
return (PyArena*)PyErr_NoMemory();
}
arena->a_objects = PyList_New(0);
if (!arena->a_objects) {
block_free(arena->a_head);
- free((void *)arena);
+ PyMem_Free((void *)arena);
return (PyArena*)PyErr_NoMemory();
}
#if defined(Py_DEBUG)
@@ -173,7 +173,7 @@ PyArena_Free(PyArena *arena)
*/
Py_DECREF(arena->a_objects);
- free(arena);
+ PyMem_Free(arena);
}
void *