// mmalloc_detach(__mmalloc_default_mdp);
xbt_mheap_destroy_no_free(__mmalloc_default_mdp);
}
+
+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;
+ }
+ }
+ }
+
+ fprintf(stderr, "check fraghead ok\n");
+
+}
size_t requested_size = size; // The amount of memory requested by user, for real
+ check_fraghead(mdp);
+
/* Work even if the user was stupid enough to ask a ridicullously small block (even 0-length),
* ie return a valid block that can be realloced and freed.
* glibc malloc does not use this trick but return a constant pointer, but we need to enlist the free fragments later on.
mdp->heapinfo[block].busy_block.bt_size=xbt_backtrace_no_malloc(mdp->heapinfo[block].busy_block.bt,XBT_BACKTRACE_SIZE);
mdp -> heapstats.chunks_used++;
mdp -> heapstats.bytes_used += blocks * BLOCKSIZE;
+
+ check_fraghead(mdp);
+
return result;
}
/* Need large block(s), but found some in the existing heap */
}
//printf("(%s) Done mallocing. Result is %p\n",xbt_thread_self_name(),result);fflush(stdout);
+ check_fraghead(mdp);
return (result);
}
#define LOCK(mdp) sem_wait(&mdp->sem)
#define UNLOCK(mdp) sem_post(&mdp->sem)
+void check_fraghead(struct mdesc *mdp);
+
#endif /* __MMPRIVATE_H */