X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/d013cec453ee914baf3c62275ea2042c41e7c270..13e0c316176dfe56c04b66d96b65a174e76d0549:/src/xbt/mmalloc/mm_module.c diff --git a/src/xbt/mmalloc/mm_module.c b/src/xbt/mmalloc/mm_module.c index 0dfd0279e1..6341fa8683 100644 --- a/src/xbt/mmalloc/mm_module.c +++ b/src/xbt/mmalloc/mm_module.c @@ -339,9 +339,9 @@ void *mmalloc_preinit(void) void mmalloc_postexit(void) { - /* Do not detach the default mdp or ldl won't be able to free the memory it allocated since we're in memory */ - // mmalloc_detach(__mmalloc_default_mdp); - xbt_mheap_destroy_no_free(__mmalloc_default_mdp); + /* Do not destroy the default mdp or ldl won't be able to free the memory it + * allocated since we're in memory */ + // xbt_mheap_destroy_no_free(__mmalloc_default_mdp); } size_t mmalloc_get_bytes_used(xbt_mheap_t heap){ @@ -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]; + } + +}