1 #include "xbt/mmalloc.h"
11 XBT_LOG_NEW_DEFAULT_CATEGORY(test,"this test");
13 #define BUFFSIZE 204800
16 int main(int argc, char**argv)
19 void *pointers[TESTSIZE];
22 XBT_INFO("Allocating a new heap");
23 heapA = xbt_mheap_new(-1, ((char*)sbrk(0)) + BUFFSIZE);
25 perror("attach 1 failed");
26 fprintf(stderr, "bye\n");
30 XBT_INFO("HeapA allocated");
33 for (i = 0; i < TESTSIZE; i++) {
34 size = ((i % 10)+1)* 100;
35 pointers[i] = mmalloc(heapA, size);
36 XBT_INFO("%d bytes allocated with offset %lu", size, ((char*)pointers[i])-((char*)heapA));
39 for (i = 0; i < TESTSIZE; i++) {
43 mfree(heapA, pointers[i]);
45 mfree(heapA, pointers[i]);
51 xbt_die("FAIL: A double-free went undetected (for size:%d)",((i%10)+1)*100);
54 XBT_INFO("Done; bye bye");