Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
mmap on ios
// It's tested on ios 8.2 ..
// Apple document about virtual memory:
// Both OS X and iOS include a fully-integrated virtual memory system that you cannot turn off; it is always on.
// Discussing mmap on ios:
#include <sys/mman.h>
void test_mmap_ios(NSURL* url) {
FILE *fd = fopen([[url path] UTF8String], "r");
fseek(fd, 0, SEEK_END);
int len = (int)ftell(fd);
fseek( fd, 0, SEEK_SET );
void *map = mmap(0, len, PROT_READ, MAP_SHARED, fileno( fd), 0);
if (map == MAP_FAILED) {
printf( "MAP_FAILED. errno=%d", errno );
} else {
printf( "MAP SUCCEEDED.");
munmap(map, len);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.