mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +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
|
@ -3118,7 +3118,7 @@ static int _setup_ssl_threads(void) {
|
|||
if (_ssl_locks == NULL) {
|
||||
_ssl_locks_count = CRYPTO_num_locks();
|
||||
_ssl_locks = (PyThread_type_lock *)
|
||||
malloc(sizeof(PyThread_type_lock) * _ssl_locks_count);
|
||||
PyMem_Malloc(sizeof(PyThread_type_lock) * _ssl_locks_count);
|
||||
if (_ssl_locks == NULL)
|
||||
return 0;
|
||||
memset(_ssl_locks, 0,
|
||||
|
@ -3130,7 +3130,7 @@ static int _setup_ssl_threads(void) {
|
|||
for (j = 0; j < i; j++) {
|
||||
PyThread_free_lock(_ssl_locks[j]);
|
||||
}
|
||||
free(_ssl_locks);
|
||||
PyMem_Free(_ssl_locks);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue