[PATCH 04/11] FindModuleInSubdir: Stop allocating one more byte than needed

Alan Coopersmith alan.coopersmith at oracle.com
Tue Nov 30 09:01:51 PST 2010


Matt Turner wrote:
> On Tue, Nov 30, 2010 at 4:57 AM, Alan Coopersmith
> <alan.coopersmith at oracle.com> wrote:
>> 15ac25627e7239629be59 removed the "/" from the sprintf strings,
>> but failed to remove the extra byte allocated for the '/'.
>
> Good catch. Did you just happen to notice this, or find it in some
> more automated way?
> 
> Reviewed-by: Matt Turner <mattst88 at gmail.com>
> 
> Is there any reason we shouldn't use Xasprintf here instead of malloc+sprintf?

I noticed it when grep'ing for sprintf calls that could be converted to
Xasprintf, and figured it would be clearer in the history to get rid
of the extra allocation first (recording why) than to just have the
Xasprintf conversion quietly drop the extra bytes.   Also if there was
disagreement over Xasprintf, this patch could still go in on it's own.

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list