Mercurial > hg > Game > Cerium
changeset 1987:1420e4521b4a draft
implement my_read in word_count
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 18 Apr 2014 13:50:49 +0900 |
parents | c05e575da760 |
children | f13abbbaaf72 |
files | example/word_count/main.cc |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/example/word_count/main.cc Fri Apr 18 02:11:16 2014 +0900 +++ b/example/word_count/main.cc Fri Apr 18 13:50:49 2014 +0900 @@ -51,8 +51,6 @@ my_read(char *filename, WordCount *w) { /*マッピングだよ!*/ - int map = MAP_PRIVATE; - st_mmap_t st_mmap; struct stat sb; long fd = w->fd; @@ -65,9 +63,11 @@ } //madvise(w->file_mmap, w->read_filesize, POSIX_MADV_NORMAL); - w->file_mmap = (char*)mmap(NULL,w->read_filesize,PROT_READ,map,fd,(off_t)0); + //w->file_mmap = (char*)mmap(NULL,w->read_filesize,PROT_READ,map,fd,(off_t)0); + w->file_mmap = (char*)malloc(w->read_filesize); + read(fd, w->file_mmap, w->read_filesize); - if (st_mmap.file_mmap == (caddr_t)-1) { + if (w->file_mmap == (caddr_t)-1) { fprintf(stderr,"Can't mmap file\n"); perror(NULL); exit(0);