public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Alastair Hume <ahume@csl.co.uk>
To: "'pthreads-win32@sources.redhat.com'"
	<pthreads-win32@sources.redhat.com>
Subject: RE: Memory leak in pthread_setcanceltype()?
Date: Thu, 28 Sep 2000 09:20:00 -0000	[thread overview]
Message-ID: <9114362C5989D311928C005004A82520391AC0@lethe.csl.co.uk> (raw)

> I don't know for a fact, but I'd be leary about calling
pthread_mutex_destroy()
> 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
array
> allocated on the stack to me.  I certainly wouldn't depend on calling
> pthread_mutex_destroy() on a mutex not initialized via
pthread_mutex_init() to
> 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
PTHREAD_MUTEX_INITIALIZER macro."

Thanks to all who helped,

Ally Hume

             reply	other threads:[~2000-09-28  9:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-28  9:20 Alastair Hume [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-09-28 10:53 Bossom, John
2000-09-28  8:57 reentrant
2000-09-27  7:17 Alastair Hume
2000-09-27  7:40 ` Ross Johnson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9114362C5989D311928C005004A82520391AC0@lethe.csl.co.uk \
    --to=ahume@csl.co.uk \
    --cc=pthreads-win32@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).