#include "utils.h" int readToTab(long* tab, char* file){ int n = 0; int fd = open(file, O_RDONLY); if(fd == -1){ perror("open"); exit(1); } char tmp[1000]; memset(tmp, 0, 1000); char temp; size_t j = 0, x=0; read(fd,&temp,sizeof(char)); while(temp != '.'){ if(temp != ' '){ tmp[x] = temp; x++; } else if(temp == ' '){ long t = atol(tmp); tab[j] = t; memset(tmp, 0, 1000); j++; x=0; n++; } read(fd,&temp,sizeof(char)); } return n-1; } 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 nb, size_t *l){ long* t; size_t taille_tab = 0; if(l == NULL){ taille_tab = (size_t)(random()+1)%100; } else{ taille_tab = nb; } t = malloc(sizeof(long)*taille_tab); memset(t, 0, taille_tab); *l= taille_tab; size_t i = 0; for(i = 0; i<taille_tab; i++){ long p = (long)(rand()%1000); t[i] = p; } return t; } 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); }