Subject: Re: alloca in the kernel
To: matthew green <email@example.com>
From: Lennart Augustsson <firstname.lastname@example.org>
Date: 01/06/2002 03:03:25
alloca() is nasty, let's avoid it in the kernel.
matthew green wrote:
> Line 227 of sys/arch/macppc/macppc/machdep.c reads 'ofmap =
> alloca(ofmaplen);', which in turn causes
> cc1: warnings being treated as errors
> /vol/NetBSD/build/src/sys/arch/macppc/macppc/machdep.c: In function `initppc':
> /vol/NetBSD/build/src/sys/arch/macppc/macppc/machdep.c:227: warning: implicit
> declaration of function `alloca'
> /vol/NetBSD/build/src/sys/arch/macppc/macppc/machdep.c:227: warning:
> assignment makes pointer from integer without a cast
> *** Error code 1
> when cross compiling using build.sh on NetBSD/i386. This is all with -current.
> I have checked, and this is the only use of alloca in any kernel code in any
> NetBSD port. Should it be replaced with malloc/free?
> does this file include libkern.h? alloca() recently moved to being
> a GCC builtin #define, and we use cc -ffreestanding, and files using
> alloca() need to include libkern.h.