From: Marion Guthmuller Date: Sat, 21 Sep 2013 20:07:58 +0000 (+0200) Subject: model-checker : get size used (heapinfo meta-data) X-Git-Tag: v3_9_90~104^2~34 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5091520484cfb65451327eb49cfe4c423a010628 model-checker : get size used (heapinfo meta-data) --- diff --git a/include/xbt/mmalloc.h b/include/xbt/mmalloc.h index df40f030d3..edc4efb78a 100644 --- a/include/xbt/mmalloc.h +++ b/include/xbt/mmalloc.h @@ -64,5 +64,6 @@ void reset_heap_information(void); int get_pointed_area_size(void *area, int heap); size_t mmalloc_get_bytes_used(xbt_mheap_t); +ssize_t mmalloc_get_busy_size(xbt_mheap_t, void *ptr); #endif /* MMALLOC_H */ diff --git a/src/xbt/mmalloc/mm_module.c b/src/xbt/mmalloc/mm_module.c index 0dfd0279e1..01c0bce8c2 100644 --- a/src/xbt/mmalloc/mm_module.c +++ b/src/xbt/mmalloc/mm_module.c @@ -365,3 +365,16 @@ size_t mmalloc_get_bytes_used(xbt_mheap_t heap){ return bytes; } +ssize_t mmalloc_get_busy_size(xbt_mheap_t heap, void *ptr){ + + ssize_t block = ((char*)ptr - (char*)(heap->heapbase)) / BLOCKSIZE + 1; + if(heap->heapinfo[block].type == -1) + return -1; + else if(heap->heapinfo[block].type == 0) + return heap->heapinfo[block].busy_block.busy_size; + else{ + ssize_t frag = ((uintptr_t) (ADDR2UINT (ptr) % (BLOCKSIZE))) >> heap->heapinfo[block].type; + return heap->heapinfo[block].busy_frag.frag_size[frag]; + } + +}