+ assert(0);
+
+ fprintf(stderr,"Cannot mmap file '%s' for reading [%s].\n",filename,strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
+ mappedfiles=(struct mmapinfo*)realloc((void*)mappedfiles,(nmappedfiles+1)*sizeof(struct mmapinfo));
+
+ mappedfiles[nmappedfiles].filename=filename;
+ mappedfiles[nmappedfiles].fd=fd;
+ mappedfiles[nmappedfiles].address=address;
+ mappedfiles[nmappedfiles].length=size;
+
+ nmappedfiles++;
+
+ return(address);
+}
+
+
+/*++++++++++++++++++++++++++++++++++++++
+ Open a file and map it into memory.
+
+ void *MapFileWriteable Returns the address of the file or exits in case of an error.
+
+ const char *filename The name of the file to open.
+ ++++++++++++++++++++++++++++++++++++++*/
+
+void *MapFileWriteable(const char *filename)
+{
+ int fd;
+ off_t size;
+ void *address;
+
+ /* Open the file and get its size */
+
+ fd=ReOpenFileWriteable(filename);
+
+ size=SizeFile(filename);
+
+ /* Map the file */
+
+ address=mmap(NULL,size,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
+
+ if(address==MAP_FAILED)
+ {
+ close(fd);
+
+ fprintf(stderr,"Cannot mmap file '%s' for reading and writing [%s].\n",filename,strerror(errno));