[PATCH 2 of 2] osutil.c: replace alloca() with malloc() and remove <alloca.h>

Matt Mackall mpm at selenic.com
Mon Oct 8 15:18:31 UTC 2007


On Sun, Oct 07, 2007 at 10:00:31PM +0300, Giorgos Keramidas wrote:
> # HG changeset patch
> # User Giorgos Keramidas <keramida at ceid.upatras.gr>
> # Date 1191783522 -10800
> # Node ID 5d13d2d3f42bc150f711bfa3a8bb38a7d0b5c1d4
> # Parent  37dc732e00416a50dcc9b994961acdb6ceb755ba
> osutil.c: replace alloca() with malloc() and remove <alloca.h>
> 
> The <alloca.h> header is not really portable, and it breaks Mercurial on
> FreeBSD.  Remove the dependency on <alloca.h> and alloca() by replacing
> the only place where it was used with malloc().

It seems the most sensible thing to do here is get rid of the call
entirely and do:

	char full_path[PATH_MAX + epsilon];

up in the local variable declarations. Combined with strncat instead
of the current strcpy, of course.

So long as no one wants to run hg on a silly system like QNX with
emaciated stacks, that should be fine.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list