From c3d42c1025d2cd15373dc8b698890f12f2f91f75 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Thu, 28 Jul 2005 17:39:27 +0000 Subject: [PATCH] Fixed mmap bug, and GUI memory leak. This was SVN commit r2560. --- source/gui/scripting/JSInterface_IGUIObject.cpp | 2 ++ source/lib/sysdep/win/wposix.cpp | 3 ++- source/ps/Errors.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/source/gui/scripting/JSInterface_IGUIObject.cpp b/source/gui/scripting/JSInterface_IGUIObject.cpp index a808cdb100..6418382f11 100755 --- a/source/gui/scripting/JSInterface_IGUIObject.cpp +++ b/source/gui/scripting/JSInterface_IGUIObject.cpp @@ -252,9 +252,11 @@ JSBool JSI_IGUIObject::getProperty(JSContext* cx, JSObject* obj, jsval id, jsval { JSString* s = StringConvert::wchars_to_jsstring(cx, value.m_Items[i].GetRawString().c_str()); vector[i] = STRING_TO_JSVAL(s); + // TODO: Make sure these strings never get garbage-collected } JSObject *obj = JS_NewArrayObject(cx, (jsint)value.m_Items.size(), vector); + delete[] vector; *vp = OBJECT_TO_JSVAL(obj); break; diff --git a/source/lib/sysdep/win/wposix.cpp b/source/lib/sysdep/win/wposix.cpp index 5e85ad1bc2..ffde234e9e 100755 --- a/source/lib/sysdep/win/wposix.cpp +++ b/source/lib/sysdep/win/wposix.cpp @@ -627,11 +627,12 @@ void* mmap(void* user_start, size_t len, int prot, int flags, int fd, off_t offs const DWORD len_hi = (DWORD)((u64)len >> 32); // careful! language doesn't allow shifting 32-bit types by 32 bits. const DWORD len_lo = (DWORD)len & 0xffffffff; - const HANDLE hMap = CreateFileMapping(hFile, &sec, flProtect, len_hi, len_lo, (LPCSTR)0); + const HANDLE hMap = CreateFileMapping(hFile, psec, flProtect, len_hi, len_lo, (LPCSTR)0); if(hMap == INVALID_HANDLE_VALUE) // bail now so that MapView.. doesn't overwrite the last error value. goto fail; void* addr = MapViewOfFileEx(hMap, dwAccess, len_hi, offset, len_lo, start); + // TODO: MapViewOfFileEx wants offset_hi rather than len_hi // free the mapping object now, so that we don't have to hold on to its // handle until munmap(). it's not actually released yet due to the diff --git a/source/ps/Errors.cpp b/source/ps/Errors.cpp index b7245ef798..45bb1a1c0b 100755 --- a/source/ps/Errors.cpp +++ b/source/ps/Errors.cpp @@ -170,7 +170,7 @@ PSRETURN PSERROR_System_VmodeFailed::getCode() const { return 0x08000003; } PSRETURN PSERROR_Xeromyces_XMLOpenFailed::getCode() const { return 0x09000001; } PSRETURN PSERROR_Xeromyces_XMLParseError::getCode() const { return 0x09000002; } -const char* PSERROR::what() const +const char* PSERROR::what() const throw () { return GetErrorString(getCode()); }