English Language flag
// Log In
// CVSweb
Project: FreeWRT
// Summary // Activity // Search // Tracker // Lists // News // SCM // Wiki

SCM Repository

ViewVC logotype

Diff of /branches/common-nfo/tools/nfotiser/parser.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3451 by tg, Wed Aug 8 16:51:04 2007 UTC revision 3452 by tg, Thu Aug 9 11:22:16 2007 UTC
# Line 97  nfo_parse(int fd, const struct parser_ke Line 97  nfo_parse(int fd, const struct parser_ke
97          if (fstat(fd, &sb))          if (fstat(fd, &sb))
98                  err(255, "cannot stat");                  err(255, "cannot stat");
99    
100          buf = mmap(NULL, (len = sb.st_size), PROT_READ, MAP_FILE, fd, 0);          /* slurp whole file into mapped memory */
101          if (buf == MAP_FAILED)          if ((cp = mmap(NULL, (len = sb.st_size), PROT_READ, MAP_FILE, fd, 0))
102                == MAP_FAILED)
103                  err(255, "cannot mmap %zu bytes", len);                  err(255, "cannot mmap %zu bytes", len);
104            /* make a nice NUL-terminated copy (malloc'd) */
105            buf = str_nsave(cp, len);
106            if (munmap(cp, len))
107                    err(255, "cannot munmap");
108            /* don't need the file any more */
109            close(fd);
110    
111            /* now we can operate on the NUL-terminated R/W string “buf” */

Legend:
Removed from v.3451  
changed lines
  Added in v.3452

root@freewrt.org:443
ViewVC Help
Powered by ViewVC 1.1.20