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: RFC: introduce scoped cleanups


Joel> A very valid concern, IMO! I've never seen heap allocation as
Joel> a reason for concern with respect to performance, and thus have
Joel> never hesitated calling malloc. The only reason I have prefered
Joel> alloca whenever possible is that it allows me to be lazy :-)!

It doesn't happen much, but you can see a few spots where someone coded
around the malloc call -- the various conditional cleanups that my
series removed.

Joel> But this made me realize something: Why would someone want to do
Joel> stack-cleanups instead of just calling alloca directly? Since
Joel> alloca is basically a call-and-forget, what's the advantage of
Joel> going through a stack-based cleanup?

It is the difference between running the cleanup and freeing the memory
that is used by the cleanup object itself.

Joel> Regardless of the above, I like the idea of performing the cleanups
Joel> on an obstack; fast and yet a little more resilient to programming
Joel> errors. Not sure if that would be something easy to implement or not,
Joel> though.

It ought to be easy.  I will look into it.

Tom


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