blob: 1a8b8636cce2cbdf694aa2c99d1fc6f70d805d14 [file] [log] [blame]
njn8b140de2009-02-17 04:31:18 +00001#include <assert.h>
njn83b62cb2009-04-15 03:12:43 +00002#include "tests/malloc.h"
njn8b140de2009-02-17 04:31:18 +00003#include <stdlib.h>
4#include <stdio.h>
5
6int main(void)
7{
sewardj6e9de462011-06-28 07:25:29 +00008# if !defined(VGO_darwin)
njn8b140de2009-02-17 04:31:18 +00009 // 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
njn8b140de2009-02-17 04:31:18 +000014 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}