2009-02-11 20:47:41 +00:00
|
|
|
// Includes Windows.h, has inlined versions of memory allocation and
|
|
|
|
// string comparison functions needed to avoid using CRT. This reduces
|
|
|
|
// dll size by over 100k while avoiding any dependencies on updated CRT dlls.
|
2009-02-11 09:24:56 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifndef _DEBUG
|
|
|
|
#define NO_CRT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef NO_CRT
|
|
|
|
#define _CRT_ALLOCATION_DEFINED
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define UNICODE
|
|
|
|
|
|
|
|
#define _CRT_SECURE_NO_DEPRECATE
|
2009-02-11 20:47:41 +00:00
|
|
|
// Actually works with 0x0400, but need 0x500 to get XBUTTON defines,
|
|
|
|
// 0x501 to get raw input structures, and 0x0600 to get WM_MOUSEHWHEEL.
|
|
|
|
#define WINVER 0x0600
|
2009-02-11 09:24:56 +00:00
|
|
|
#define _WIN32_WINNT WINVER
|
|
|
|
#define __MSCW32__
|
|
|
|
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
extern HINSTANCE hInst;
|
|
|
|
|
|
|
|
#ifdef NO_CRT
|
|
|
|
inline void * malloc(size_t size) {
|
|
|
|
return HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void * calloc(size_t num, size_t size) {
|
|
|
|
size *= num;
|
|
|
|
void *out = malloc(size);
|
|
|
|
if (out) memset(out, 0, size);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void free(__inout_opt void * mem) {
|
|
|
|
if (mem) HeapFree(GetProcessHeap(), 0, mem);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void * realloc(void *mem, size_t size) {
|
|
|
|
if (!mem) {
|
|
|
|
return malloc(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!size) {
|
|
|
|
free(mem);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return HeapReAlloc(GetProcessHeap(), 0, mem, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline wchar_t * __cdecl wcsdup(const wchar_t *in) {
|
|
|
|
size_t size = sizeof(wchar_t) * (1+wcslen(in));
|
|
|
|
wchar_t *out = (wchar_t*) malloc(size);
|
|
|
|
if (out)
|
|
|
|
memcpy(out, in, size);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2009-02-11 20:47:41 +00:00
|
|
|
inline void * __cdecl operator new(size_t lSize) {
|
2009-02-11 09:24:56 +00:00
|
|
|
return HeapAlloc(GetProcessHeap(), 0, lSize);
|
|
|
|
}
|
|
|
|
|
2009-02-11 20:47:41 +00:00
|
|
|
inline void __cdecl operator delete(void *pBlock) {
|
2009-02-11 09:24:56 +00:00
|
|
|
HeapFree(GetProcessHeap(), 0, pBlock);
|
|
|
|
}
|
|
|
|
|
2009-02-11 20:47:41 +00:00
|
|
|
inline int __cdecl wcsicmp(const wchar_t *s1, const wchar_t *s2) {
|
2009-02-11 09:24:56 +00:00
|
|
|
int res = CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE, s1, -1, s2, -1);
|
|
|
|
if (res) return res-2;
|
|
|
|
return res;
|
|
|
|
}
|
2009-02-11 20:47:41 +00:00
|
|
|
|
|
|
|
#endif
|