Commit d0c8d898 authored by cdf009's avatar cdf009

lab 7 done

parent 883b1aab
...@@ -39,7 +39,7 @@ int deallocate(void *ptr){ ...@@ -39,7 +39,7 @@ int deallocate(void *ptr){
struct dnode* dealloc; struct dnode* dealloc;
dealloc = dlist_find_remove(allocated_list, ptr); dealloc = dlist_find_remove(allocated_list, ptr);
printf("%x deallocating node %x, %d", ptr, dealloc->data, dealloc->size); // printf("%x deallocating node %x, %d", ptr, dealloc->data, dealloc->size);
dlist_add_back(free_list, dealloc->data, dealloc->size); dlist_add_back(free_list, dealloc->data, dealloc->size);
return 0; return 0;
} }
...@@ -93,7 +93,6 @@ struct dnode* first_fit(int size){ ...@@ -93,7 +93,6 @@ struct dnode* first_fit(int size){
} }
if (free_list->back == current){ if (free_list->back == current){
printf("No space in list"); printf("No space in list");
return -1;
} }
...@@ -121,7 +120,7 @@ struct dnode* best_fit(int size){ ...@@ -121,7 +120,7 @@ struct dnode* best_fit(int size){
} }
while(iter); while(iter);
if (min_size == 0){ if (min_size == 0){
return -1; printf("No space in list");
} }
databest = dlist_add_back(allocated_list, minimum->data, size); databest = dlist_add_back(allocated_list, minimum->data, size);
minimum->size -= size; minimum->size -= size;
...@@ -151,7 +150,7 @@ struct dnode* worst_fit(int size){ ...@@ -151,7 +150,7 @@ struct dnode* worst_fit(int size){
} }
while (iter); while (iter);
if (max_size == 0){ if (max_size == 0){
return -1; printf("No space in list!");
} }
dataworst = dlist_add_back(allocated_list, maximum->data, size); dataworst = dlist_add_back(allocated_list, maximum->data, size);
maximum->size -= size; maximum->size -= size;
......
...@@ -69,15 +69,6 @@ int main(){ ...@@ -69,15 +69,6 @@ int main(){
deallocate(opt2->data); deallocate(opt2->data);
allocator_print(); allocator_print();
printf("\n");
printf("Allocating 900");
printf("\n");
allocate(800, 1);
allocator_print();
printf("No change because there is not enough memory");
printf("\n");
printf("\n");
allocator_init(1000); allocator_init(1000);
printf("\n"); printf("\n");
...@@ -100,15 +91,6 @@ int main(){ ...@@ -100,15 +91,6 @@ int main(){
deallocate(opt2->data); deallocate(opt2->data);
allocator_print(); allocator_print();
printf("\n");
printf("Allocating 800");
printf("\n");
allocate(800, 2);
allocator_print();
printf("No change because there is not enough memory");
printf("\n");
printf("\n");
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment