diff options
author | Chris Lattner <sabre@nondot.org> | 2006-07-07 17:32:37 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-07-07 17:32:37 +0000 |
commit | 5a9d2e5a0a66a28fc322437b0146eb5b1b368087 (patch) | |
tree | 877a5ae3eb4f11d6dd139031b3584e83166c3fc2 /llvm/lib/System/Win32 | |
parent | 1fb6e0d79da834bed4ff965ae4ad876f583afce4 (diff) | |
download | bcm5719-llvm-5a9d2e5a0a66a28fc322437b0146eb5b1b368087.tar.gz bcm5719-llvm-5a9d2e5a0a66a28fc322437b0146eb5b1b368087.zip |
Change AllocateRWX/DeallocateRWX to not throw an exception.
llvm-svn: 29058
Diffstat (limited to 'llvm/lib/System/Win32')
-rw-r--r-- | llvm/lib/System/Win32/Memory.inc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/System/Win32/Memory.inc b/llvm/lib/System/Win32/Memory.inc index 7e93dee24eb..9f5693a9aae 100644 --- a/llvm/lib/System/Win32/Memory.inc +++ b/llvm/lib/System/Win32/Memory.inc @@ -23,7 +23,9 @@ using namespace sys; //=== 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 @@ MemoryBlock Memory::AllocateRWX(unsigned NumBytes, const MemoryBlock* NearBlock) 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 @@ MemoryBlock Memory::AllocateRWX(unsigned NumBytes, const MemoryBlock* NearBlock) 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); } } |