Created
May 15, 2009 18:08
-
-
Save dreadpiratepj/112348 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void *nmapFile(int sizeInBytes, FILE *myFile) { | |
if (myFile) { | |
/* Get the file descriptor from the FILE pointer. */ | |
int fd = fileno(myFile); | |
if (fd >= 0) { | |
/* Map the file into an unused area of the process's address space. */ | |
void *result = mmap( | |
NULL, /* No preferred address. */ | |
sizeInBytes, /* Size of mapped space. */ | |
PROT_READ, /* Read access. */ | |
MAP_FILE, /* Map from file (default) */ | |
fd, /* The file descriptor. */ | |
0 /* Offset from start of file. */ | |
); | |
if (result) | |
return result; | |
} | |
} | |
return NULL; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment