[llvm-commits] CVS: llvm/lib/System/Win32/Memory.inc
Chris Lattner
lattner at cs.uiuc.edu
Fri Jul 7 10:32:51 PDT 2006
Changes in directory llvm/lib/System/Win32:
Memory.inc updated: 1.6 -> 1.7
---
Log message:
Change AllocateRWX/DeallocateRWX to not throw an exception.
---
Diffs of the changes: (+8 -6)
Memory.inc | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
Index: llvm/lib/System/Win32/Memory.inc
diff -u llvm/lib/System/Win32/Memory.inc:1.6 llvm/lib/System/Win32/Memory.inc:1.7
--- llvm/lib/System/Win32/Memory.inc:1.6 Fri Jul 29 18:39:25 2005
+++ llvm/lib/System/Win32/Memory.inc Fri Jul 7 12:32:37 2006
@@ -23,7 +23,9 @@
//=== and must not be UNIX code
//===----------------------------------------------------------------------===//
-MemoryBlock Memory::AllocateRWX(unsigned NumBytes, const MemoryBlock* NearBlock) {
+MemoryBlock Memory::AllocateRWX(unsigned NumBytes,
+ const MemoryBlock *NearBlock,
+ std::string *ErrMsg) {
if (NumBytes == 0) return MemoryBlock();
static const long pageSize = Process::GetPageSize();
@@ -34,7 +36,8 @@
void *pa = VirtualAlloc(NULL, NumPages*pageSize, MEM_COMMIT,
PAGE_EXECUTE_READWRITE);
if (pa == NULL) {
- ThrowError("Can't allocate RWX Memory: ");
+ GetError("Can't allocate RWX Memory: ", ErrMsg);
+ return MemoryBlock();
}
MemoryBlock result;
@@ -43,11 +46,10 @@
return result;
}
-void Memory::ReleaseRWX(MemoryBlock& M) {
+bool Memory::ReleaseRWX(MemoryBlock &M, std::string *ErrMsg) {
if (M.Address == 0 || M.Size == 0) return;
- if (!VirtualFree(M.Address, 0, MEM_RELEASE)) {
- ThrowError("Can't release RWX Memory: ");
- }
+ if (!VirtualFree(M.Address, 0, MEM_RELEASE))
+ return GetError("Can't release RWX Memory: ", ErrMsg);
}
}
More information about the llvm-commits
mailing list