Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2003:
[Freeciv-Dev] Re: (PR#6822) some variable-sized arrays
Home

[Freeciv-Dev] Re: (PR#6822) some variable-sized arrays

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6822) some variable-sized arrays
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Mon, 10 Nov 2003 23:47:43 -0800
Reply-to: rt@xxxxxxxxxxx

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

On Mon, Nov 10, 2003 at 11:14:35PM -0800, Jason Short wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=6822 >
> 
> Raimar Falke wrote:
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=6822 >
> > 
> > On Mon, Nov 10, 2003 at 04:56:27PM -0800, Jason Short wrote:
> > 
> >><URL: http://rt.freeciv.org/Ticket/Display.html?id=6822 >
> >>
> >>The attached patch replaces some malloc'd arrays with variable-sized 
> >>stack arrays.  One memory leak is fixed in the process.
> >>
> >>This should be faster, but my tests didn't show a measurable difference 
> >>(on systems with inefficient malloc calls this may make an impact - but 
> >>then those systems aren't likely to compile C99 anyway).  It's also 
> >>safer and more legible.
> > 
> > I don't see that the benefits (safer) outweigh the costs (change must
> > be done, compiler or other tools doesn't understand it).
> 
> Compilers understanding it isn't an issue since (1) we already require 
> C99 and (2) the configure check for this particular C99 feature is 
> already done.

I was quite negative surprised to learn that splint (an automatic
tools to test the code for certain problematic patterns) doesn't
support variadic macros. If we add other features we lock up ways to
get the help of tools.

In the splint-variadic-macros case I planned to write a patch which
conditionally replace variadic macros with simple ones. So far I
haven't coded it. If this patch gets accepted is another story. In the
variable-sized-stack-arrays case however such an easy solution isn't
possible.

> I don't know that it's worth changing existing code, but new code
> should use stack arrays rather than malloc'd memory where possible.

Hmmm.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Last year, out in California, at a PC users group, there was a demo of
  smart speech recognition software. Before the demonstrator could begin
  his demo, a voice called out from the audience: "Format c, return. Yes,
  return." Damned short demo, it was.




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