3 ms·
mmap is a more ergonomic interface than read too. How often are people copying a file to a local buffer, or the whole file a chunk at a time, in order to use t
by beached_whale 6y ago
mmap is a more ergonomic interface than read too. How often are people copying a file to a local buffer, or the whole file a chunk at a time, in order to use the file like an array of bytes. mmap gives us a range of bytes right off the start. Even if not optimal, the simplicity in usage often means less room for bugs.
- lathiat 6y agoBe mindful that can give you Time Of Check/Time Of Use (TOCTOU) security bugs though. The buffer can change out from under you.
- icedchai 6y agoThat can sometimes be a feature, not a bug. I've worked on systems that used memory mapped files as a form of persistent shared memory between processes.
- beached_whale 6y agoThats the open/lock mode too. Same as without