[llvm-commits] [llvm] r49026 - in /llvm/trunk: include/llvm/System/MappedFile.h lib/System/Unix/MappedFile.inc lib/System/Win32/MappedFile.inc
Chris Lattner
sabre at nondot.org
Mon Mar 31 20:49:39 PDT 2008
Author: lattner
Date: Mon Mar 31 22:49:38 2008
New Revision: 49026
URL: http://llvm.org/viewvc/llvm-project?rev=49026&view=rev
Log:
Make MappedFile::map return a const correct pointer, don't leak address space on Unix platforms.
Modified:
llvm/trunk/include/llvm/System/MappedFile.h
llvm/trunk/lib/System/Unix/MappedFile.inc
llvm/trunk/lib/System/Win32/MappedFile.inc
Modified: llvm/trunk/include/llvm/System/MappedFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/MappedFile.h?rev=49026&r1=49025&r2=49026&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/MappedFile.h (original)
+++ llvm/trunk/include/llvm/System/MappedFile.h Mon Mar 31 22:49:38 2008
@@ -65,15 +65,13 @@
return initialize(ErrMsg);
}
- /// unmap - Remove the mapped file from memory. If the file was mapped for
- /// write access, the memory contents will be automatically synchronized
- /// with the file's disk contents.
+ /// unmap - Remove the mapped file from memory.
void unmap();
/// map - Reserve space for the file, map it into memory, and return a
/// pointer to it. This returns the base memory address of the mapped file
/// or 0 if an error occurred.
- void *map(std::string* ErrMsg = 0);
+ const void *map(std::string* ErrMsg = 0);
void close() { if (MapInfo) terminate(); }
Modified: llvm/trunk/lib/System/Unix/MappedFile.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/MappedFile.inc?rev=49026&r1=49025&r2=49026&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/MappedFile.inc (original)
+++ llvm/trunk/lib/System/Unix/MappedFile.inc Mon Mar 31 22:49:38 2008
@@ -56,6 +56,7 @@
}
void MappedFile::terminate() {
+ unmap();
assert(MapInfo && "MappedFile not initialized");
::close(MapInfo->FD);
delete MapInfo;
@@ -70,7 +71,7 @@
BasePtr = 0; // Mark this as non-mapped.
}
-void* MappedFile::map(std::string* ErrMsg) {
+const void* MappedFile::map(std::string* ErrMsg) {
assert(MapInfo && "MappedFile not initialized");
if (isMapped()) return BasePtr;
Modified: llvm/trunk/lib/System/Win32/MappedFile.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Win32/MappedFile.inc?rev=49026&r1=49025&r2=49026&view=diff
==============================================================================
--- llvm/trunk/lib/System/Win32/MappedFile.inc (original)
+++ llvm/trunk/lib/System/Win32/MappedFile.inc Mon Mar 31 22:49:38 2008
@@ -75,7 +75,7 @@
}
}
-void* MappedFile::map(std::string* ErrMsg) {
+const void* MappedFile::map(std::string* ErrMsg) {
if (!isMapped()) {
MapInfo->hMapping = CreateFileMapping(MapInfo->hFile, NULL, PAGE_READONLY,
0, 0, NULL);
More information about the llvm-commits
mailing list