Hello,
When memory mapping a file with the MAP_PRIVATE flag, the modifications (writes) only exist in memory and are not written back to the file.[snip]
So: is there a way to write the changes back to the file?[snip]
void* p2 = mmap( NULL
, n
, PROT_READ | PROT_WRITE
, MAP_SHARED | MAP_NORESERVE
, fd
, 0 );
On Sun, 07 Apr 24 15:18:47 +0000, pehache wrote:
void* p2 = mmap( NULL
, n
, PROT_READ | PROT_WRITE
, MAP_SHARED | MAP_NORESERVE
, fd
, 0 );
Not easy to remember what the arguments mean. Try this:
void * p2 = mmap^^^^ ^^^^ a null pointer is some kind of "addr"
(
/*addr =*/ NULL,
/*length =*/ n,^^^^ ^^^^
/*prot =*/ PROT_READ | PROT_WRITE,
/*flags =*/ MAP_SHARED | MAP_NORESERVE,^^^^
/*fd =*/ fd,^^ ^^
/*offset =*/ 0
);
On Sun, 07 Apr 24 15:18:47 +0000, pehache wrote:
void* p2 = mmap( NULL
, n
, PROT_READ | PROT_WRITE
, MAP_SHARED | MAP_NORESERVE
, fd
, 0 );
Not easy to remember what the arguments mean. Try this:
void * p2 = mmap
(
/*addr =*/ NULL,
/*length =*/ n,
/*prot =*/ PROT_READ | PROT_WRITE,
/*flags =*/ MAP_SHARED | MAP_NORESERVE,
/*fd =*/ fd,
/*offset =*/ 0
);
... how did you manage to figure out the meanings and
order of the parameters in order to be able to write those comments?
If you have 1000s of calls to such functions, will you have those
comments plastered everwhere?
In a language with proper named/keyword arguments, you don't need to
remember the order.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 546 |
Nodes: | 16 (1 / 15) |
Uptime: | 155:36:44 |
Calls: | 10,383 |
Files: | 14,054 |
Messages: | 6,417,848 |