Mercurial > cpython-lru_cache-weakref
diff Python/thread_pthread.h @ 84497:9af1905f20af
Issue #18203: Replace malloc() with PyMem_RawMalloc() to allocate thread locks
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Sun, 07 Jul 2013 17:17:59 +0200 |
| parents | f2e373ddfa00 |
| children |
line wrap: on
line diff
--- a/Python/thread_pthread.h Sun Jul 07 17:10:34 2013 +0200 +++ b/Python/thread_pthread.h Sun Jul 07 17:17:59 2013 +0200 @@ -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
