Skip to content
Snippets Groups Projects
Commit d72a19f8 authored by 최민정's avatar 최민정
Browse files

real

parent 56e46ac1
No related branches found
No related tags found
No related merge requests found
......@@ -102,46 +102,36 @@ void m_realoc(void* p,uint32_t size){
void m_free(void *ptr){
int index = *(int *)ptr;
int count = 0;
meta* tmp_head;
meta* temp = head;
int size = head -> size;
int break_point = 0;
while(1){
if(count == index)
break;
temp = temp -> next_memory;
if(temp -> free == 0)
count++;
}
while(1){
if(temp -> next_memory == NULL){
if(temp -> next_memory != NULL){
if(temp -> next_memory -> free == 1){
size += temp -> next_memory -> size;
temp -> next_memory = temp -> next_memory -> next_memory;
tmp_head -> next_memory = temp -> next_memory -> next_memory;
temp -> next_memory -> next_memory -> prev_memory = tmp_head;
}
else
break;
}
else
break;
}
while(1){
if(temp -> prev_memory == NULL){
tmp_head -> next_memory = NULL;
if(temp -> prev_memory != NULL){
if(temp -> prev_memory -> free == 1){
size += temp -> prev_memory -> size;
temp -> prev_memory = temp -> prev_memory -> prev_memory;
tmp_head -> prev_memory = temp -> prev_memory -> prev_memory;
temp -> prev_memory -> prev_memory -> next_memory = tmp_head;
}
else
break;
}
else
break;
}
temp -> free = 1;
tmp_head -> prev_memory = NULL;
tmp_head -> free = 1;
tmp_head -> size = size;
strcpy(temp -> comment," ");
if( index == 0)
head == temp -> next_memory;
head == tmp_head -> next_memory;
}
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment