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.
This commit is contained in:
Victor Stinner 2013-07-07 16:21:41 +02:00
parent 1a7425f67a
commit b64049183c
10 changed files with 52 additions and 55 deletions

View file

@ -117,7 +117,7 @@ insert_lop(PyCursesPanelObject *po)
{
list_of_panels *new;
if ((new = (list_of_panels *)malloc(sizeof(list_of_panels))) == NULL) {
if ((new = (list_of_panels *)PyMem_Malloc(sizeof(list_of_panels))) == NULL) {
PyErr_NoMemory();
return -1;
}
@ -136,7 +136,7 @@ remove_lop(PyCursesPanelObject *po)
temp = lop;
if (temp->po == po) {
lop = temp->next;
free(temp);
PyMem_Free(temp);
return;
}
while (temp->next == NULL || temp->next->po != po) {
@ -148,7 +148,7 @@ remove_lop(PyCursesPanelObject *po)
temp = temp->next;
}
n = temp->next->next;
free(temp->next);
PyMem_Free(temp->next);
temp->next = n;
return;
}