[PD] Fwd: Variable number of objects?
Mathieu Bouchard
matju at artengine.ca
Fri Sep 30 18:10:41 CEST 2011
Le 2011-09-30 à 12:01:00, Mathieu Bouchard a écrit :
> size_t real_size (size_t n) {return 1<<highest_bit(n+sizeof(void *));}
erratum :
size_t real_size (size_t n) {return 2<<highest_bit(n+sizeof(void *)-1);}
because the first version I wrote gets the PREVIOUS-or-equal power, which
is nonsense. Doubling that gives the NEXT power, but not next-or-equal, so
I subtract 1 to compensate for that.
BTW, I haven't looked at modern glibc mallocs. I suspect it might do
things similar to the Perl Allocator nowadays, though I have not checked,
and it's probably not documented (?). Chances are that it's a different
formula, anyway.
______________________________________________________________________
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC
More information about the Pd-list
mailing list