Skip to content
Snippets Groups Projects
Commit 0f9a9d65 authored by kim-dong-hwi's avatar kim-dong-hwi
Browse files

only make malloc

parent 81530590
No related branches found
No related tags found
No related merge requests found
#include "alloc.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
int main(int argc, char *argv[])
{
int tok,tmp,idx=0;
FILE * f;
char r_size[1000];
if((f=fopen(argv[1],"r"))==NULL)
{
printf("File open error.\n");
return -1;
}
fgets(r_size,sizeof(r_size),f);
char *ptr=strtok(r_size," ");
tok=atoi(ptr);
char **command=(char**)malloc(sizeof(char*)*tok);
ptr=strtok(NULL," ");
for(int i=0;i<tok; i++)
{
memset(r_size,'\0',sizeof(r_size)); // idx
fgets(r_size,sizeof(r_size),f); // get read
r_size[strlen(r_size)-1]='\0'; // End of string is null
if(r_size[0]=='s'){
command[idx] = make_malloc(strlen(r_size+1));
strcpy(command[idx++],r_size+1);
}
}
read_start=start;
while(read_start){
printf("free : %d / size : %d ", read_start->free,read_start->size);
if(!read_start->free)
printf("%s\n",read_start->offset);
read_start=read_start->next;
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment