November 2007
Intermediate to advanced
848 pages
27h 15m
English
The operating system makes it possible to memory map a data file into your process’ address space. Thus it is very convenient to manipulate large streams of data.
To understand the power of using memory-mapped files this way, let’s look at four possible methods of implementing a program to reverse the order of all the bytes in a file.
The first and theoretically simplest method involves allocating a block of memory large enough to hold the entire file. The file is opened, its contents are read into the memory block, and the file is closed. With the contents in memory, we can now reverse all the bytes by swapping the first byte with the last, the second byte with the second-to-last, and so on. ...
Read now
Unlock full access