Newer
Older
int fd = open(file, O_RDONLY);
if(fd == -1){
perror("open");
exit(1);
}
int n = 0;
int sizet = 1000, nb_size = 1;
int nb_size_tab = 1;
size_t x=0;
char* tmp = malloc(sizeof(char)*sizet);
memset(tmp, 0, sizet);
//printf("char:%c long:%d n:%d j:%d nb_size:%d, size:%d\n",temp,tab[j], n,j,nb_size, sizet);
if(n==TAB_SIZE*(nb_size_tab*10)){
nb_size_tab+=1;
//printf("size:%d nb_size:%d, sizef:%d\n", sizet, nb_size, sizeof(char)*(sizet*nb_size));
tab = realloc(tab, sizeof(long)*(TAB_SIZE*10));
}
//printf("size:%d nb_size:%d, sizef:%d\n", sizet, nb_size, sizeof(char)*(sizet*nb_size));
}
void initData(struct data* d){
d->time = 0;
d->comparison = 0;
d->ct_fusion = 0;
d->ct_parse = 0;
d->write = 0;
}
long* generate_tab(size_t max, size_t length){
if(length==0){
return 0;
long* tab = malloc(sizeof(long)*length+1);
memset(tab, 0, sizeof(long)*length+1);
size_t index = 0;
for(index = 0; index<length; index++){
long p = (long)(rand()%max);
tab[index] = p;
}
void printData(struct data d){
printf("Time passed : %ld\n", d.time);
printf("Number of comparison : %ld\n", d.comparison);
printf("Number of write : %ld\n", d.write);
printf("Call of fusion : %ld\n", d.ct_fusion);
printf("Call of parsing : %ld\n", d.ct_parse);