This is the mail archive of the
mailing list for the pthreas-win32 project.
RE: Memory leak in pthread_setcanceltype()?
- To: "'pthreads-win32 at sources dot redhat dot com'" <pthreads-win32 at sources dot redhat dot com>
- Subject: RE: Memory leak in pthread_setcanceltype()?
- From: Alastair Hume <ahume at csl dot co dot uk>
- Date: Thu, 28 Sep 2000 17:19:45 +0100
> I don't know for a fact, but I'd be leary about calling
> on a mutex not initialized with pthread_mutex_init() (i.e. initialied with
> PTHREAD_MUTEX_INITIALIZER). It feels like free()ing a pointer to a char
> allocated on the stack to me. I certainly wouldn't depend on calling
> pthread_mutex_destroy() on a mutex not initialized via
> be portable.
> From the sound of it, to be safe I'd personally recommend avoiding the
> PTHREAD_MUTEX_INITIALIZER and use pthread_mutex_init() to initialize and
> pthread_mutex_destroy() to destroy.
That's what I've done now and the memory leaks have gone away. Seems fairly
sensible to me and I'm happy with this.
My original implementation was done after reading Butenhof's "Programming
with POSIX Threads" (Addison-Wesley) which said on page 51, "You do not need
to destroy a mutex that was statically initialized using the
Thanks to all who helped,