This is the mail archive of the gdb-patches@sources.redhat.com 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: PATCH: allocate namecopy on heap, not stack


Daniel Jacobowitz <drow@false.org> writes:

> On Fri, Apr 29, 2005 at 04:35:35PM -0500, Jim Blandy wrote:
> > 
> > Committed as obvious.
> > 
> > 2005-04-28  Jim Blandy  <jimb@redhat.com>
> > 
> > 	* parse.c (namecopy): Change allocation conventions.
> > 	(namecopy_size): New variable.
> > 	(copy_name): Allocate namecopy using xrealloc, instead of assuming
> > 	it has adequate space allocated to it.
> > 	(parse_exp_1): Don't try to allocate space for namecopy here.
> 
> What prompted ths change?  Even "obvious" patches deserve an
> explanation.

Certainly --- did you see this?

+ 
+ /* A temporary buffer for identifiers, so we can null-terminate them.
+ 
+    We allocate this with xrealloc.  parse_exp_1 used to allocate with
+    alloca, using the size of the whole expression as a conservative
+    estimate of the space needed.  However, macro expansion can
+    introduce names longer than the original expression; there's no
+    practical way to know beforehand how large that might be.  */
+ char *namecopy;
+ size_t namecopy_size;


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