This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [OB] Add cleanup, source.c


On Thu, Jun 28, 2007 at 06:36:38PM -0700, msnyder@sonic.net wrote:
> > No, that's not right.  Cleanups are often discarded after a successful
> > operation, in order to not free something that would have been cleaned
> > up on error.
> 
> Well, I'm pretty sure you're mistaken.

We're both right.  Cleanups do get discarded, and cleanups that aren't
discarded are called at the top level.  Every cleanup I've written
since I started working on GDB at 2001 has been freed locally rather
than at the top level, though.  I think it's very confusing if the
cleanups are not locally paired.

>From gdbint.texinfo:

   Your function should explicitly do or discard the cleanups it
creates.  Failing to do this leads to non-deterministic behavior since
the caller will arbitrarily do or discard your functions cleanups.
This need leads to two common cleanup styles.

> 3) By example: in the same module (source.c), three other functions
> call buildargv and make_cleanup_freeargv -- and none of them calls
> do_cleanups.
> 
> So you're holding me to a higher standard than the preexisting code.
> ;-)

True.  There are several functions that do though.  Well, I'll stop
objecting now :-)

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]