[DGD]Sizeof arrays...

Jason Cone jcone at uscdev.com
Tue Jun 19 22:44:21 CEST 2001


> -----Original Message-----
> From: Michael J. Bacon [mailto:mj.bacon at gte.net]
> Sent: Tuesday, June 19, 2001 3:23 PM
> To: dgd at list.imaginary.com
> Subject: RE: [DGD]Sizeof arrays...
> 
> 
> 	Nevermind - found it, for a mapping its (map->size)/2, 
> and array its just
> array->size.


Close. ;)

For arrays, you are correct; it's (array*)->size

For maps, however, the size can be determined via (*):

    unsigned short nSize;

    /* Optimized division by 2 (using integer division, of course) */
    nSize = (array*)->size >> 1;

    /* This is the part that you are missing */
    if ( (array*)->hashed != NULL )
    {
        nSize += (array*)->hashed->size;
    }


(*) -- The above code was effectively copied from array.c->map_size().

List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list