|
|
@ -30,9 +30,12 @@ extern char* mmap_shared(const char* filename,size_t * filesize) {
|
|
|
|
register off_t o=lseek(fd,0,SEEK_END);
|
|
|
|
register off_t o=lseek(fd,0,SEEK_END);
|
|
|
|
if (sizeof(off_t)!=sizeof(size_t) && o > (off_t)(size_t)-1) { close(fd); return 0; }
|
|
|
|
if (sizeof(off_t)!=sizeof(size_t) && o > (off_t)(size_t)-1) { close(fd); return 0; }
|
|
|
|
*filesize=(size_t)o;
|
|
|
|
*filesize=(size_t)o;
|
|
|
|
|
|
|
|
if (o) {
|
|
|
|
map=mmap(0,*filesize,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
|
|
|
|
map=mmap(0,*filesize,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
|
|
|
|
if (map==(char*)-1)
|
|
|
|
if (map==(char*)-1)
|
|
|
|
map=0;
|
|
|
|
map=0;
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
map="";
|
|
|
|
close(fd);
|
|
|
|
close(fd);
|
|
|
|
return map;
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
}
|
|
|
|