From 12232b03d266f9a2cefbb51bc672fc8db541b15c Mon Sep 17 00:00:00 2001 From: janwas Date: Wed, 2 Feb 2005 03:26:38 +0000 Subject: [PATCH] win_internal: winnt version=0x0501 for HeapSetInformation (to enable LFH) win.cpp: enable low-fragmentation heap (if available) This was SVN commit r1888. --- source/lib/sysdep/win/win.cpp | 17 +++++++++++++++++ source/lib/sysdep/win/win_internal.h | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/source/lib/sysdep/win/win.cpp b/source/lib/sysdep/win/win.cpp index 9ed3406acf..f55352bb13 100755 --- a/source/lib/sysdep/win/win.cpp +++ b/source/lib/sysdep/win/win.cpp @@ -355,6 +355,23 @@ static void at_exit(void) // be very careful to avoid non-stateless libc functions! static inline void pre_libc_init() { +#if WINVER >= 0x0501 + // enable low-fragmentation heap + HMODULE hKernel32Dll = LoadLibrary("kernel32.dll"); + if(hKernel32Dll) + { + BOOL (WINAPI* pHeapSetInformation)(HANDLE, HEAP_INFORMATION_CLASS, void*, size_t); + *(void**)&pHeapSetInformation = GetProcAddress(hKernel32Dll, "HeapSetInformation"); + if(pHeapSetInformation) + { + ULONG flags = 2; // enable LFH + HeapSetInformation(GetProcessHeap(), HeapCompatibilityInformation, &flags, sizeof(flags)); + } + + FreeLibrary(hKernel32Dll); + } +#endif // #if WINVER >= 0x0501 + cs_init(); GetSystemDirectory(win_sys_dir, sizeof(win_sys_dir)); diff --git a/source/lib/sysdep/win/win_internal.h b/source/lib/sysdep/win/win_internal.h index 1e73c8e0d7..028c0e0a08 100755 --- a/source/lib/sysdep/win/win_internal.h +++ b/source/lib/sysdep/win/win_internal.h @@ -38,7 +38,7 @@ #undef _WINDOWS_ // set version; needed for EnumDisplayDevices -#define _WIN32_WINNT 0x0500 +#define _WIN32_WINNT 0x0501