PATCH: malloc.c cleanups

Greg McGary greg@mcgary.org
Tue Jul 18 09:34:00 GMT 2000


Wolfram Gloger <wmglo@dent.med.uni-muenchen.de> writes:

> They all look just fine to me, except for this:
> 
> > -#define next_bin(b)    ((mbinptr)((char*)(b) + 2 * sizeof(mbinptr)))
> > -#define prev_bin(b)    ((mbinptr)((char*)(b) - 2 * sizeof(mbinptr)))
> > +#define next_bin(b)    ((mbinptr)((char*)(b) + 2 * sizeof(((arena*)0)->av[0])))
> > +#define prev_bin(b)    ((mbinptr)((char*)(b) - 2 * sizeof(((arena*)0)->av[0])))
> 
> which I don't really consider an improvement.
> 
> Do changes like these really make a difference for BP, i.e. can more
> errors be detected?  If yes, that's pretty cool.

It's a maintenance aid more than anything else, since it guarantees
that next_bin & prev_bin will always be correct with respect to the
size of the array elements of av[].  I might want the av[] to be an
array of unbounded mbinptr, or I might want them to be bounded (I
prefer bounded, but right now I have some difficulties doing that, so
I've fallen back to unbounded).  Without this change, if I qaulify the
pointer elements of av[], I must also qualify the type arg of sizeof.

Greg


More information about the Libc-hacker mailing list