Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: [FreeCiv-Cvs] rfalke: Cleanup: replace "sizeof(x)/size
Home

[Freeciv-Dev] Re: [FreeCiv-Cvs] rfalke: Cleanup: replace "sizeof(x)/size

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Freeciv Developers <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [FreeCiv-Cvs] rfalke: Cleanup: replace "sizeof(x)/sizeof(x[0])" wi...
From: Justin Moore <justin@xxxxxxxxxxx>
Date: Fri, 7 Sep 2001 13:54:45 -0400 (EDT)

> > > Cleanup: replace "sizeof(x)/sizeof(x[0])" with a new macro
> > > ARRAY_SIZE.
> > >
> >
> > This is a very good idea, but I think the name should be ARRAY_LEN to
> > since the value returned is the number of elements, rather than
> > something you can pass to malloc().
>
> This is exactly what I feared: a long discussion about the name of the
> thing. Experience told us that the discussion will not come to a
> consensus. So I just applied it. If you find the name wrong lets
> discuss this in a long thread and IF there is a consensus you have
> just to s/ARRAY_SIZE/ARRAY_LEN/.

   I actually agree with Gaute on this one.  Size is something that gets
passed to malloc, and length is the number of elements in an array.  I
would see ARRAY_SIZE as:

#define ARRAY_SIZE(x) sizeof(x)

where 'x' just happens to be, well, an array. :)

-jdm (also hoping this won't turn into another prolonged discussion)

Department of Computer Science, Duke University, Durham, NC 27708-0129
Email:  justin@xxxxxxxxxxx



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