X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2e9105988280d1e88b5b496d6e2eed4c8d541883..c128702f75d1981c4a082ae6e4630f614074ab6e:/src/xbt/mmalloc/mm_module.c 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]; + } + +}