[llvm-commits] CVS: llvm/lib/System/Win32/DynamicLibrary.cpp
Reid Spencer
reid at x10sys.com
Sat Nov 20 15:48:57 PST 2004
Changes in directory llvm/lib/System/Win32:
DynamicLibrary.cpp updated: 1.1 -> 1.2
---
Log message:
Cast the void* handle data member to HMODULE* to keep the VC++ compiler
happy. Thanks to Henrik Bach for pointing this out.
---
Diffs of the changes: (+9 -5)
Index: llvm/lib/System/Win32/DynamicLibrary.cpp
diff -u llvm/lib/System/Win32/DynamicLibrary.cpp:1.1 llvm/lib/System/Win32/DynamicLibrary.cpp:1.2
--- llvm/lib/System/Win32/DynamicLibrary.cpp:1.1 Wed Nov 17 22:33:40 2004
+++ llvm/lib/System/Win32/DynamicLibrary.cpp Sat Nov 20 17:30:55 2004
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "Win32.h"
+#include <windef.h>
namespace llvm {
using namespace sys;
@@ -22,9 +23,10 @@
//===----------------------------------------------------------------------===//
DynamicLibrary::DynamicLibrary(const char*filename) : handle(0) {
- handle = LoadLibrary(filename);
+ handle = new HMODULE;
+ *((HMODULE*)handle) = LoadLibrary(filename);
- if (handle == 0) {
+ if (*((HMODULE*)handle) == 0) {
char Buffer[100];
// FIXME: This should use FormatMessage
sprintf(Buffer, "Windows error code %d\n", GetLastError());
@@ -33,13 +35,15 @@
}
DynamicLibrary::~DynamicLibrary() {
- if (handle)
- FreeLibrary(handle);
+ assert(handle !=0 && "Invalid DynamicLibrary handle");
+ if (*((HMODULE*)handle))
+ FreeLibrary(*((HMODULE*)handle));
+ delete (HMODULE*)handle;
}
void *DynamicLibrary::GetAddressOfSymbol(const char *symbolName) {
assert(handle !=0 && "Invalid DynamicLibrary handle");
- return GetProcAddress(handle, symbolName);
+ return (void*) GetProcAddress(*((HMODULE*)handle), symbolName);
}
}
More information about the llvm-commits
mailing list