summaryrefslogtreecommitdiffstats
path: root/Modules/_lsprof.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-07 14:21:41 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-07 14:21:41 (GMT)
commitb64049183cee61edc112eefa3ca76916d03e9f02 (patch)
treefd0be14ac288739314a5108c6e21879f641b0b40 /Modules/_lsprof.c
parent1a7425f67a0d141483d89ca80ca01e3cb7f6be92 (diff)
downloadcpython-b64049183cee61edc112eefa3ca76916d03e9f02.zip
cpython-b64049183cee61edc112eefa3ca76916d03e9f02.tar.gz
cpython-b64049183cee61edc112eefa3ca76916d03e9f02.tar.bz2
Issue #18203: Replace malloc() with PyMem_Malloc() in Python modules
Replace malloc() with PyMem_Malloc() when the GIL is held, or with PyMem_RawMalloc() otherwise.
Diffstat (limited to 'Modules/_lsprof.c')
-rw-r--r--Modules/_lsprof.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c
index 5657f2f..fef255f 100644
--- a/Modules/_lsprof.c
+++ b/Modules/_lsprof.c
@@ -223,7 +223,7 @@ static ProfilerEntry*
newProfilerEntry(ProfilerObject *pObj, void *key, PyObject *userObj)
{
ProfilerEntry *self;
- self = (ProfilerEntry*) malloc(sizeof(ProfilerEntry));
+ self = (ProfilerEntry*) PyMem_Malloc(sizeof(ProfilerEntry));
if (self == NULL) {
pObj->flags |= POF_NOMEMORY;
return NULL;
@@ -231,7 +231,7 @@ newProfilerEntry(ProfilerObject *pObj, void *key, PyObject *userObj)
userObj = normalizeUserObj(userObj);
if (userObj == NULL) {
PyErr_Clear();
- free(self);
+ PyMem_Free(self);
pObj->flags |= POF_NOMEMORY;
return NULL;
}
@@ -264,7 +264,7 @@ static ProfilerSubEntry *
newSubEntry(ProfilerObject *pObj, ProfilerEntry *caller, ProfilerEntry* entry)
{
ProfilerSubEntry *self;
- self = (ProfilerSubEntry*) malloc(sizeof(ProfilerSubEntry));
+ self = (ProfilerSubEntry*) PyMem_Malloc(sizeof(ProfilerSubEntry));
if (self == NULL) {
pObj->flags |= POF_NOMEMORY;
return NULL;
@@ -282,7 +282,7 @@ newSubEntry(ProfilerObject *pObj, ProfilerEntry *caller, ProfilerEntry* entry)
static int freeSubEntry(rotating_node_t *header, void *arg)
{
ProfilerSubEntry *subentry = (ProfilerSubEntry*) header;
- free(subentry);
+ PyMem_Free(subentry);
return 0;
}
@@ -291,7 +291,7 @@ static int freeEntry(rotating_node_t *header, void *arg)
ProfilerEntry *entry = (ProfilerEntry*) header;
RotatingTree_Enum(entry->calls, freeSubEntry, NULL);
Py_DECREF(entry->userObj);
- free(entry);
+ PyMem_Free(entry);
return 0;
}
@@ -301,13 +301,13 @@ static void clearEntries(ProfilerObject *pObj)
pObj->profilerEntries = EMPTY_ROTATING_TREE;
/* release the memory hold by the ProfilerContexts */
if (pObj->currentProfilerContext) {
- free(pObj->currentProfilerContext);
+ PyMem_Free(pObj->currentProfilerContext);
pObj->currentProfilerContext = NULL;
}
while (pObj->freelistProfilerContext) {
ProfilerContext *c = pObj->freelistProfilerContext;
pObj->freelistProfilerContext = c->previous;
- free(c);
+ PyMem_Free(c);
}
pObj->freelistProfilerContext = NULL;
}
@@ -393,7 +393,7 @@ ptrace_enter_call(PyObject *self, void *key, PyObject *userObj)
else {
/* free list exhausted, allocate a new one */
pContext = (ProfilerContext*)
- malloc(sizeof(ProfilerContext));
+ PyMem_Malloc(sizeof(ProfilerContext));
if (pContext == NULL) {
pObj->flags |= POF_NOMEMORY;
goto restorePyerr;
@@ -712,7 +712,7 @@ flush_unmatched(ProfilerObject *pObj)
else
pObj->currentProfilerContext = pContext->previous;
if (pContext)
- free(pContext);
+ PyMem_Free(pContext);
}
}