[Python-checkins] cpython: Issue #18203: Replace malloc() with PyMem_RawMalloc() to allocate thread locks
victor.stinner
python-checkins at python.org
Sun Jul 7 17:26:35 CEST 2013
http://hg.python.org/cpython/rev/9af1905f20af
changeset: 84497:9af1905f20af
user: Victor Stinner <victor.stinner at gmail.com>
date: Sun Jul 07 17:17:59 2013 +0200
summary:
Issue #18203: Replace malloc() with PyMem_RawMalloc() to allocate thread locks
files:
Python/thread_nt.h | 8 ++++----
Python/thread_pthread.h | 12 ++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/Python/thread_nt.h b/Python/thread_nt.h
--- a/Python/thread_nt.h
+++ b/Python/thread_nt.h
@@ -34,7 +34,7 @@
PNRMUTEX
AllocNonRecursiveMutex()
{
- PNRMUTEX m = (PNRMUTEX)malloc(sizeof(NRMUTEX));
+ PNRMUTEX m = (PNRMUTEX)PyMem_RawMalloc(sizeof(NRMUTEX));
if (!m)
return NULL;
if (PyCOND_INIT(&m->cv))
@@ -46,7 +46,7 @@
m->locked = 0;
return m;
fail:
- free(m);
+ PyMem_RawFree(m);
return NULL;
}
@@ -56,7 +56,7 @@
if (mutex) {
PyCOND_FINI(&mutex->cv);
PyMUTEX_FINI(&mutex->cs);
- free(mutex);
+ PyMem_RawFree(mutex);
}
}
@@ -107,7 +107,7 @@
result = PyCOND_SIGNAL(&mutex->cv);
result &= PyMUTEX_UNLOCK(&mutex->cs);
return result;
-}
+}
#else /* if ! _PY_USE_CV_LOCKS */
diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h
--- a/Python/thread_pthread.h
+++ b/Python/thread_pthread.h
@@ -282,14 +282,14 @@
if (!initialized)
PyThread_init_thread();
- lock = (sem_t *)malloc(sizeof(sem_t));
+ lock = (sem_t *)PyMem_RawMalloc(sizeof(sem_t));
if (lock) {
status = sem_init(lock,0,1);
CHECK_STATUS("sem_init");
if (error) {
- free((void *)lock);
+ PyMem_RawFree((void *)lock);
lock = NULL;
}
}
@@ -313,7 +313,7 @@
status = sem_destroy(thelock);
CHECK_STATUS("sem_destroy");
- free((void *)thelock);
+ PyMem_RawFree((void *)thelock);
}
/*
@@ -410,7 +410,7 @@
if (!initialized)
PyThread_init_thread();
- lock = (pthread_lock *) malloc(sizeof(pthread_lock));
+ lock = (pthread_lock *) PyMem_RawMalloc(sizeof(pthread_lock));
if (lock) {
memset((void *)lock, '\0', sizeof(pthread_lock));
lock->locked = 0;
@@ -430,7 +430,7 @@
CHECK_STATUS("pthread_cond_init");
if (error) {
- free((void *)lock);
+ PyMem_RawFree((void *)lock);
lock = 0;
}
}
@@ -457,7 +457,7 @@
status = pthread_mutex_destroy( &thelock->mut );
CHECK_STATUS("pthread_mutex_destroy");
- free((void *)thelock);
+ PyMem_RawFree((void *)thelock);
}
PyLockStatus
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list