PATCH: malloc.c cleanups
Wolfram Gloger
wmglo@dent.med.uni-muenchen.de
Wed Jul 19 01:16: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[].
OK, I see. It's probably a matter of taste, but I would prefer to see
sizeof(main_arena.av[0]) used rather than the cast NULL pointer. My C
standard draft says that expressions `usually' aren't evaluated within
sizeof, but only in a footnote.
Regards,
Wolfram.
More information about the Libc-hacker
mailing list