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

@ -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;
}
}