Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : get size used (heapinfo meta-data)
authorMarion Guthmuller <marion.guthmuller@loria.fr>
Sat, 21 Sep 2013 20:07:58 +0000 (22:07 +0200)
committerMarion Guthmuller <marion.guthmuller@loria.fr>
Sat, 21 Sep 2013 20:50:29 +0000 (22:50 +0200)
include/xbt/mmalloc.h
src/xbt/mmalloc/mm_module.c

index df40f03..edc4efb 100644 (file)
@@ -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 */
index 0dfd027..01c0bce 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];
+  }
+    
+}