Hi,
I'm trying to project a file into memory to operate with it. The file contais structs so I'm trying to use a pointer to the start of one struct and then read it and modify some variable. The problem is that the time of execution is high and I suppose that using mmap the time will be less. This is the code, any suggestion?
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>
int revisanotas(int fd)
{
int nbytes=1;
int nbytese=0;
int i=0;
int n=0;
struct stat datos;
fstat(fd, &datos);
evaluacion buf;
evaluacion* buffer=mmap(0,datos.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
int actual = read(fd,buffer,datos.st_size);
{
i++;
if (buffer[i].notamedia >= 4.5 && buffer[i].notamedia < 5)
{
n=n+1;
printf("Notamedia = %f\n",buffer[i].notamedia);
buffer[i].notamedia=5;
}
}while (i<(datos.st_size/(sizeof(evaluacion))));
return