nanogui@linuxhacker.org
nanogui@linuxhacker.org
Subject: Re: alloca()
From: Brent Thompson
Date: Wed, 11 Oct 2000 13:38:01 -0500
Greg Haerr wrote:
> : Is this replacement something that could be rolled into the
> : general release in order to make Microwindows more portable
> : to new platforms?
>
> Send me the changes. I suppose we should include
> malloc/free instead of alloca, since too few systems
> implement it. However, alloca is way faster than malloc,
> so I'll look at how it's used and perhaps save this for
> the day Microwindows has a ./configure setup.
Agreed. What would you think about macro-izing this?
Say:
#ifdef USE_ALLOCA
#define ALLOCA(size) alloca(size)
#define FREEA(pmem)
#else /* no alloca(), so use malloc()/free() instead */
#define ALLOCA(size) malloc(size)
#define FREEA(pmem) free(pmem)
#endif
Then always use ALLOCA() & FREEA() properly so that
malloc()/free() works. But if there is an alloca()
available, define USE_ALLOCA and all is faster! :-)
BAT
--
Brent A. Thompson, Next Level Communications <www.nlc.com>
1776 22nd Street #100, West Des Moines, IA 50266-1444
EMail: <Thompson@nlc.com>, Phone: (515)991-3853
nanogui@linuxhacker.org