This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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 sufficient space for string buffer


On Thu, Jun 07, 2012 at 11:58:45AM -0700, H.J. Lu wrote:
> 	* input-scrub.c (input_scrub_include_sb): Use sb_build to
> 	allocate sufficient space for from_sb.
> 	* read.c (do_repeat): Use sb_build to allocate sufficient space
> 	for many.
> 	* sb.c (sb_build): Remove static.
> 	* sb.h (sb_build): New prototype.

Seems a reasonable optimisation.  OK, but

> -  sb_new (&many);
> +  sb_build (&many, count * one.len + 1);

looks wrong to me.  sb_build already adds one to account for the
string terminator.

-- 
Alan Modra
Australia Development Lab, IBM


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