I have a memory-mapped file and I'm writing changes to the memory region returned, but they don't appear to take.
The stderr shows the values:
int des = open("processed.dat", O_RDWR | O_CREAT | O_NOATIME, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
assert(des != -1);
void *buf = mmap(NULL, SIZEOFTHESUCKA, PROT_READ | PROT_WRITE, MAP_PRIVATE, des, 0);
assert(buf != MAP_FAILED);
... //some code that writes to buf
const unsigned char *p = (const unsigned char *)buf;
for (int i = 0; i < SIZEOFTHESUCKA; i++)
fprintf(stderr, "%02X ", (int)p[i]);
assert(munmap(buf, SIZEOFTHESUCKA) == 0);
But when I call:
6D 00 00 04 00 16 33 12
I only get:
I should also point out that before the file is opened it is already SIZEOFTHESUCKA bytes long, and is zeroed.
0000000 0000 0000 0000 0000
NDEBUG is not defined, so munmap() does get called.