mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
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:
parent
1a7425f67a
commit
b64049183c
10 changed files with 52 additions and 55 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue