Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Andrew Cagney <ac131313@redhat.com>
To: David Carlton <carlton@math.stanford.edu>
Cc: gdb <gdb@sources.redhat.com>
Subject: Re: How much should I cleanup?
Date: Mon, 17 Feb 2003 14:58:00 -0000	[thread overview]
Message-ID: <3E4F585E.1020700@redhat.com> (raw)
In-Reply-To: <ro1d6lygzcs.fsf@jackfruit.Stanford.EDU>

> When is it important to make sure that I have cleanups in place?  My
> understanding is that it's important if I have control of a block of
> memory that I want to xfree() after doing some work, but where that
> xfree() might not be reached because of exceptional circumstances.

Just assume the exception is the norm - you're going to need to do a 
clean-up.  The internals doco suggests several conventions.

> So, if that's correct: what are 'exceptional circumstances'?  I assume
> error() and related functions count.  I don't know exactly what QUIT
> does; do I have to be careful if there are QUIT's in between the
> xmalloc() and the xfree()?  (Are those the only places where GDB pays
> attention to ^C's?)  Any other situations?

Failed memory read, no frame.

> Sigh.  C has its benefits, but ease of memory management isn't one of
> them.  Every time I have to write a cleanup function, every time I
> have to think about whether to alloca() memory for a string or to
> xmalloc() it (and every time I can't alloca() it because I'm returning
> the string in question), I get another grey hair.  (Though the grey
> hair falls out soon thereafter, for better or for worse.)

Ah, yes.  C++ `is the answer' :-^

> David Carlton
> carlton@math.stanford.edu

Andrew



  reply	other threads:[~2003-02-17 14:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-11 23:40 David Carlton
2003-02-17 14:58 ` Andrew Cagney [this message]
2003-02-17 16:46   ` David Carlton

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=3E4F585E.1020700@redhat.com \
    --to=ac131313@redhat.com \
    --cc=carlton@math.stanford.edu \
    --cc=gdb@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