Skip to content

Instantly share code, notes, and snippets.

@jverkoey
Created June 25, 2012 01:03
Show Gist options
  • Save jverkoey/2985830 to your computer and use it in GitHub Desktop.
Save jverkoey/2985830 to your computer and use it in GitHub Desktop.
Memory mapping in Objective-C
const char* cstr = [string UTF8String];
void* anon = mmap(0, sizeof(char) * (string.length + 1), PROT_WRITE|PROT_READ, MAP_ANON|MAP_PRIVATE, 0, 0);
if (anon == MAP_FAILED) {
NSLog(@"Failed to map memory.");
return;
}
strcpy(anon, cstr);
// How do I get a file descriptor for use here?
markdownin = fdopen(fd, "r");
@jverkoey
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment