Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] Re: (PR#7279) Macro optimizations
Home

[Freeciv-Dev] Re: (PR#7279) Macro optimizations

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: a-l@xxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7279) Macro optimizations
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Wed, 21 Jan 2004 10:25:11 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7279 >

On Wed, Jan 21, 2004 at 09:24:46AM -0800, Arnstein Lindgard wrote:
> > Use of alloca() to create temporary stack space is a potential
> > compatibility issue, but can be removed by making preallocation
> > of local storage in env a requirement or part of the definition
> > macro rather than option.

> Assuming we need local variables:
> 
> My linux man pages says alloca() is non POSIX and it's use is
> discouraged. Some existing Freeciv code (which looks imported)
> substitutes alloca() with malloc() if you don't have a requirement,
> and that introduces overhead for one function call in your macro.

Indeed. alloca is forbidden in freeciv. Note that C99 provides a
portable replacement: variable sized arrays. So 

int f(int n)
{
  char *p=alloca(n);

becomes

int f(int n)
{
  char p[n];

But I have the feeling that this doesn't help here.

> bool normalize_map_pos(int *x, int *y)    would become
> normalize_map_pos(ENV, X, Y)

I'm sure that this won't happen.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "We just typed make..."
    -- Stephen Lambrigh, Director of Server Product Marketing at Informix,
                         about porting their Database to Linux




[Prev in Thread] Current Thread [Next in Thread]