From: <ni...@in...> - 2001-05-23 00:44:35
|
I asked: > What is this mmap() actually doing, apart from allocating memory? Christian answered: > It can allocate memory at a program-specified address > (and optionally read- or write-protect the area). Sure. What I actually meant was, what is this mmap() doing: RAMBaseHost = (uint8 *)mmap(0, mapped_ram_rom_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, zero_fd, 0); From my reading of the manpage: * The load address (0) is ignored because MAP_FIXED isn't set * MAP_PRIVATE makes a copy of mapped_ram_rom_size bytes from zero_fd when the process first writes to the memory block So, how is this really any different to: RAMBaseHost = (uint8 *)malloc(mapped_ram_rom_size); memset(RAMBaseHost, mapped_ram_rom_size, sizeof(uint8)); or RAMBaseHost = (uint8 *)calloc(mapped_ram_rom_size, sizeof(uint8)); -- | Nigel Pearson, ni...@in... | "Reality is that which, | | Telstra NW-D, Sydney, Australia. | when you stop believing | | Office: 9206 3468 Fax: 9212 6329 | in it, doesn't go away." | | Mobile: 0408 664435 Home: 9792 6998 | Philip K. Dick - 'Valis.' | |