Select Git revision
Forked from
HyukSang Kwon / 1801_OS_assignment4
Source project has a limited visibility.
-
Hywon woong Jang authoredHywon woong Jang authored
main.c 1.15 KiB
#include "alloc.h"
int main()
{
int num;
char * str[100];
char move[4096]; // enough size;
meta * temp = NULL;
char * save = NULL;
char flag;
int size;
int sequence;
int n = 0;
int i= 0;
scanf("%d %c",&num, &Algorithm);
for(i=0; i < num; i++)
{
// printf("here?\n");
scanf(" %c",&flag);
if(flag == 'r')
{
scanf(" %d %d",&sequence , &size);
temp = choose_meta(sequence);
temp = m_realloc(temp + 1 , size);
}
else if(flag == 's')
{
// printf("asdf\n");
scanf(" %[^\n]",move);
// printf("size : %d\n", strlen(move));
str[n] = m_malloc(strlen(move) +1);
strcpy(str[n++], move);
// printf("strlen : %d\n" ,strlen(str[n -1]));
}
else if(flag == 'f')
{
scanf(" %d",&sequence);
// printf("sequence = %d \n",sequence);
temp = choose_meta(sequence);
m_free(temp + 1);
}
else if(flag == 'e')
{
scanf(" %d",&size);
m_malloc(size);
}
}
temp = META.Head;
i=0;
printf("\n");
while(temp != NULL)
{
save = temp + 1;
printf("%d %d",temp ->free, temp->size);
if(temp -> free == 0)
printf(" %s\n", save);
else
printf("\n");
temp = temp ->next;
}
// printf("\n");
// print_link();
return 0;
}