search for: zerosizeptr

Displaying 1 result from an estimated 1 matches for "zerosizeptr".

Did you mean: zero_size_ptr
2006 Dec 11
2
malloc(0) returns 0x800 on FreeBSD 6.2 ?
...n by this program: > more a.c #include <stdio.h> int main(int argc, char *argv[]) { char *p = malloc(0); printf(" malloc 0 returns %p\n", p); } > cc -o a a.c > ./a malloc 0 returns 0x800 if you look at the source this is indeed clear - internally the 0x800 is ZEROSIZEPTR and is set when a zero length is passed to malloc() unless you have malloc_sysv set. The thing is, i don't know if this behaviour is intentional or not, but certainly is not documented -- the manpage documents something totally different (in the section for the 'V' MALLOC_OPTION, see b...