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: [RFA] c++/11734


No comments on the idea of the patch itself, just
a quick comment on something that made me stop for a second
while skimming your patch:

On Tuesday 22 June 2010 02:22:03, Keith Seitz wrote:
> +                 new = alloca (strlen (name));

Note that alloca in a loop in general isn't a good idea.  The
stack memory added in each iteration is only released on function
exit, not on each iteration, so you're prone to stack overflow
given enough loops.  It looks like `name' is invariant in
this loop, so you could for example, move the `new' declaration
out of the loop, initialized as NULL, and allocate it only once
on first need.

> +                 memcpy (new, name, paren - name);
> +                 new[name - paren] = '\0';

-- 
Pedro Alves


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