njn | 8b140de | 2009-02-17 04:31:18 +0000 | [diff] [blame] | 1 | #include <assert.h> |
njn | 83b62cb | 2009-04-15 03:12:43 +0000 | [diff] [blame] | 2 | #include "tests/malloc.h" |
njn | 8b140de | 2009-02-17 04:31:18 +0000 | [diff] [blame] | 3 | #include <stdlib.h> |
| 4 | #include <stdio.h> |
| 5 | |
| 6 | int main(void) |
| 7 | { |
sewardj | 6e9de46 | 2011-06-28 07:25:29 +0000 | [diff] [blame] | 8 | # if !defined(VGO_darwin) |
njn | 8b140de | 2009-02-17 04:31:18 +0000 | [diff] [blame] | 9 | // Because our allocations are in multiples of 8 or 16, 99 will round up |
| 10 | // to 104 or 112. |
| 11 | int* x = malloc(99); |
| 12 | |
| 13 | // XXX: would be better to have a HAVE_MALLOC_USABLE_SIZE variable here |
njn | 8b140de | 2009-02-17 04:31:18 +0000 | [diff] [blame] | 14 | assert(104 == malloc_usable_size(x) || |
| 15 | 112 == malloc_usable_size(x)); |
| 16 | assert( 0 == malloc_usable_size(NULL)); |
| 17 | assert( 0 == malloc_usable_size((void*)0xdeadbeef)); |
| 18 | # endif |
| 19 | |
| 20 | return 0; |
| 21 | } |