Adapt windows code to new memory management system (keep track of length

at time of memory free)
This commit is contained in:
Eric Scharff 2008-01-10 10:31:13 -07:00
parent 13aaa14a41
commit 4bce07ea12

View File

@ -99,7 +99,7 @@ class MySystem: public System {
CloseHandle(event); CloseHandle(event);
CloseHandle(mutex); CloseHandle(mutex);
CloseHandle(thread); CloseHandle(thread);
s->free(this); s->free(this, sizeof(*this));
} }
HANDLE thread; HANDLE thread;
@ -309,7 +309,7 @@ class MySystem: public System {
virtual void dispose() { virtual void dispose() {
assert(s, owner_ == 0); assert(s, owner_ == 0);
CloseHandle(mutex); CloseHandle(mutex);
s->free(this); s->free(this, sizeof(*this));
} }
System* s; System* s;
@ -340,7 +340,7 @@ class MySystem: public System {
bool r UNUSED = TlsFree(key); bool r UNUSED = TlsFree(key);
assert(s, r); assert(s, r);
s->free(this); s->free(this, sizeof(*this));
} }
System* s; System* s;
@ -372,7 +372,7 @@ class MySystem: public System {
if (mapping) CloseHandle(mapping); if (mapping) CloseHandle(mapping);
if (file) CloseHandle(file); if (file) CloseHandle(file);
} }
system->free(this); system->free(this, sizeof(*this));
} }
System* system; System* system;
@ -384,11 +384,13 @@ class MySystem: public System {
class Library: public System::Library { class Library: public System::Library {
public: public:
Library(System* s, HMODULE handle, const char* name, bool mapName, Library(System* s, HMODULE handle, const char* name, size_t nameLength,
bool mapName,
System::Library* next): System::Library* next):
s(s), s(s),
handle(handle), handle(handle),
name_(name), name_(name),
nameLength(nameLength),
mapName_(mapName), mapName_(mapName),
next_(next) next_(next)
{ } { }
@ -426,15 +428,16 @@ class MySystem: public System {
} }
if (name_) { if (name_) {
s->free(name_); s->free(name_, nameLength+1);
} }
s->free(this); s->free(this, sizeof(*this));
} }
System* s; System* s;
HMODULE handle; HMODULE handle;
const char* name_; const char* name_;
size_t nameLength;
bool mapName_; bool mapName_;
System::Library* next_; System::Library* next_;
}; };
@ -643,7 +646,7 @@ class MySystem: public System {
} }
*lib = new (System::allocate(sizeof(Library))) *lib = new (System::allocate(sizeof(Library)))
Library(this, handle, n, mapName, next); Library(this, handle, n, mapName, nameLength, next);
return 0; return 0;
} else { } else {
return 1; return 1;