[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]
On Fri, Sep 07, 2001 at 01:54:45PM -0400, Justin Moore wrote:
>
> > > > 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)
IMHO NR_ITEMS(x) or ARRAY_ELEMENTS(x) is better than "size" or
"length".
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"From what I am reading Win98 and NT5.0 will be getting rid of all that
crap anyway. Seems that Microsoft has invented something called TCP/IP and
another really revolutionary concept called DNS that eliminates the
netbios crap too. All that arping from browsers is going to go away.
I also hear rumors that they are on the verge of breakthrough discoveries
called NFS, and LPD too. Given enough time and money, they might
eventually invent Unix."
-- George Bonser in linux-kernel
|
|