|
@@ -23,7 +23,8 @@
|
|
|
/**
|
|
|
* \details The maptable of the heap is being traversed sequentially while
|
|
|
* searching for a size equal of the requested size. If one is found, then we
|
|
|
- * return the head of this list and set the next block as the new head.
|
|
|
+ * return the head of this list (provided that it is not null) and set the next
|
|
|
+ * block as the new head.
|
|
|
*/
|
|
|
void * search_on_fixed(heap_t * heap, size_t requested_size) {
|
|
|
maptable_node_t *node;
|
|
@@ -33,6 +34,9 @@ void * search_on_fixed(heap_t * heap, size_t requested_size) {
|
|
|
ptr = NULL;
|
|
|
|
|
|
while(node) {
|
|
|
+#ifdef COUNT_HOPS
|
|
|
+ heap->dmm_stats.total_hops++;
|
|
|
+#endif /* COUNT_HOPS */
|
|
|
if(node->size == requested_size) {
|
|
|
ptr = node->fixed_list_head;
|
|
|
if(ptr != NULL) {
|
|
@@ -73,6 +77,9 @@ void * best_fit_on_freelist(heap_t *heap, size_t requested_size) {
|
|
|
|
|
|
for(current_block = heap->free_list_head; current_block != NULL;
|
|
|
current_block = get_next(current_block)) {
|
|
|
+#ifdef COUNT_HOPS
|
|
|
+ heap->dmm_stats.total_hops++;
|
|
|
+#endif /* COUNT_HOPS */
|
|
|
block_size = get_size(current_block);
|
|
|
if(block_size >= requested_size) {
|
|
|
if(block_size < best_size) {
|
|
@@ -128,6 +135,9 @@ void * good_fit_on_freelist(heap_t *heap, size_t requested_size) {
|
|
|
|
|
|
for(current_block = heap->free_list_head; current_block != NULL;
|
|
|
current_block = get_next(current_block)) {
|
|
|
+#ifdef COUNT_HOPS
|
|
|
+ heap->dmm_stats.total_hops++;
|
|
|
+#endif /* COUNT_HOPS */
|
|
|
block_size = get_size(current_block);
|
|
|
if(block_size >= requested_size) {
|
|
|
if(block_size < best_size) {
|
|
@@ -183,6 +193,9 @@ void * exact_fit_on_freelist(heap_t *heap, size_t requested_size) {
|
|
|
|
|
|
for(current_block = heap->free_list_head; current_block != NULL;
|
|
|
current_block = get_next(current_block)) {
|
|
|
+#ifdef COUNT_HOPS
|
|
|
+ heap->dmm_stats.total_hops++;
|
|
|
+#endif /* COUNT_HOPS */
|
|
|
if(get_size(current_block) == requested_size) {
|
|
|
if(current_block == heap->free_list_head) {
|
|
|
heap->free_list_head = get_next(current_block);
|
|
@@ -217,6 +230,9 @@ void * first_fit_on_freelist(heap_t *heap, size_t requested_size) {
|
|
|
|
|
|
for(current_block = heap->free_list_head; current_block != NULL;
|
|
|
current_block = get_next(current_block)) {
|
|
|
+#ifdef COUNT_HOPS
|
|
|
+ heap->dmm_stats.total_hops++;
|
|
|
+#endif /* COUNT_HOPS */
|
|
|
if(get_size(current_block) >= requested_size) {
|
|
|
if(current_block == heap->free_list_head) {
|
|
|
heap->free_list_head = get_next(current_block);
|