-void check_fraghead(struct mdesc *mdp){
-
- struct list* next;
- int j;
-
- for (j=8; j<12; j++){
- next = mdp->fraghead[j].next;
- if(next != NULL){
- while(next->next != NULL){
- if(next->next->prev == NULL);
- next = next->next;
+size_t mmalloc_get_bytes_used(xbt_mheap_t heap){
+ int i = 0, j = 0;
+ int bytes = 0;
+
+ while(i<=((struct mdesc *)heap)->heaplimit){
+ if(((struct mdesc *)heap)->heapinfo[i].type == MMALLOC_TYPE_UNFRAGMENTED){
+ if(((struct mdesc *)heap)->heapinfo[i].busy_block.busy_size > 0)
+ bytes += ((struct mdesc *)heap)->heapinfo[i].busy_block.busy_size;
+
+ } else if(((struct mdesc *)heap)->heapinfo[i].type > 0){
+ for(j=0; j < (size_t) (BLOCKSIZE >> ((struct mdesc *)heap)->heapinfo[i].type); j++){
+ if(((struct mdesc *)heap)->heapinfo[i].busy_frag.frag_size[j] > 0)
+ bytes += ((struct mdesc *)heap)->heapinfo[i].busy_frag.frag_size[j];