mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #18203: Replace malloc() with PyMem_RawMalloc() at Python initialization
* Replace malloc() with PyMem_RawMalloc() * Replace PyMem_Malloc() with PyMem_RawMalloc() where the GIL is not held. * _Py_char2wchar() now returns a buffer allocated by PyMem_RawMalloc(), instead of PyMem_Malloc()
This commit is contained in:
parent
51fa458d0a
commit
1a7425f67a
8 changed files with 76 additions and 76 deletions
|
@ -231,7 +231,7 @@ find_key(int key, void *value)
|
|||
assert(p == NULL);
|
||||
goto Done;
|
||||
}
|
||||
p = (struct key *)malloc(sizeof(struct key));
|
||||
p = (struct key *)PyMem_RawMalloc(sizeof(struct key));
|
||||
if (p != NULL) {
|
||||
p->id = id;
|
||||
p->key = key;
|
||||
|
@ -270,7 +270,7 @@ PyThread_delete_key(int key)
|
|||
while ((p = *q) != NULL) {
|
||||
if (p->key == key) {
|
||||
*q = p->next;
|
||||
free((void *)p);
|
||||
PyMem_RawFree((void *)p);
|
||||
/* NB This does *not* free p->value! */
|
||||
}
|
||||
else
|
||||
|
@ -324,7 +324,7 @@ PyThread_delete_key_value(int key)
|
|||
while ((p = *q) != NULL) {
|
||||
if (p->key == key && p->id == id) {
|
||||
*q = p->next;
|
||||
free((void *)p);
|
||||
PyMem_RawFree((void *)p);
|
||||
/* NB This does *not* free p->value! */
|
||||
break;
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ PyThread_ReInitTLS(void)
|
|||
while ((p = *q) != NULL) {
|
||||
if (p->id != id) {
|
||||
*q = p->next;
|
||||
free((void *)p);
|
||||
PyMem_RawFree((void *)p);
|
||||
/* NB This does *not* free p->value! */
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue