8 Commits

Author SHA1 Message Date
Rich Felker
2afebbbcd1 malloc: cast size down to int in bin_index functions
even if size_t was 32-bit already, the fact that the value was
unsigned and that gcc is too stupid to figure out it would be positive
as a signed quantity (due to the immediately-prior arithmetic and
conditionals) results in gcc compiling the integer-to-float conversion
as zero extension to 64 bits followed by an "fildll" (64 bit)
instruction rather than a simple "fildl" (32 bit) instruction on x86.
reportedly fildll is very slow on certain p4-class machines; even if
not, the new code is slightly smaller.
2011-06-12 10:53:42 -04:00
Rich Felker
71a80c5767 use volatile pointers for intentional-crash code. 2011-06-06 18:10:43 -04:00
Rich Felker
b052f13cd1 namespace fixes for sys/mman.h 2011-04-20 15:55:58 -04:00
Rich Felker
b761bd19aa fix rare but nasty under-allocation bug in malloc with large requests
the bug appeared only with requests roughly 2*sizeof(size_t) to
4*sizeof(size_t) bytes smaller than a multiple of the page size, and
only for requests large enough to be serviced by mmap instead of the
normal heap. it was only ever observed on 64-bit machines but
presumably could also affect 32-bit (albeit with a smaller window of
opportunity).
2011-04-04 17:26:41 -04:00
Rich Felker
bf8785825a avoid over-allocation of brk on first malloc
if init_malloc returns positive (successful first init), malloc will
retry getting a chunk from the free bins rather than expanding the
heap again. also pass init_malloc a hint for the size of the initial
allocation.
2011-04-01 23:07:03 -04:00
Rich Felker
0958200166 very cheap double-free checks in malloc 2011-03-23 13:24:00 -04:00
Rich Felker
26031da0f8 make malloc(0) return unique pointers rather than NULL
this change is made with some reluctance, but i think it's for the
best. correct programs must handle either behavior, so there is little
advantage to having malloc(0) return NULL. and i managed to actually
make the malloc code slightly smaller with this change.
2011-02-20 16:16:33 -05:00
Rich Felker
0b44a0315b initial check-in, version 0.5.0 2011-02-12 00:22:29 -05:00