]> AND Public Git Repository - simgrid.git/blobdiff - src/xbt/mmalloc/mm_module.c
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix buf introduces by previous commit
[simgrid.git] / src / xbt / mmalloc / mm_module.c
index 0dfd0279e130f2684f85466d192226d8147f64d7..01c0bce8c2fac3f419c0b9dc2dc27e51a832adbb 100644 (file)
@@ -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];
+  }
+    
+}