Mercurial > dwindows
diff win/dw.c @ 2398:4de830d3bf9e
Win: Remove winmain.c as it is unnecessary when using the dwmain() entrypoint macros.
Export _dw_convertargs() internal function for use in the dwmain macro.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 25 Mar 2021 21:38:58 +0000 |
parents | fad0821cb953 |
children | 0286ac44d347 |
line wrap: on
line diff
--- a/win/dw.c Thu Mar 25 20:51:53 2021 +0000 +++ b/win/dw.c Thu Mar 25 21:38:58 2021 +0000 @@ -410,16 +410,23 @@ }; #ifdef BUILD_DLL +/* Old function to store the instance handle, kept for compatibilty. */ void Win32_Set_Instance(HINSTANCE hInstance) { _DWInstance = hInstance; } -#else -char **_convertargs(int *count, char *start) +#endif + +/* + * Internal function to convert WinMain arguments into main() style. + * Also saves the handle to the instance passed from WinMain(). + */ +char ** API _dw_convertargs(int *count, char *start, HINSTANCE hInstance) { char *tmp, *argstart, **argv; int loc = 0, inquotes = 0; + _DWInstance = hInstance; (*count) = 1; tmp = start; @@ -450,7 +457,7 @@ } } - argv = (char **)malloc(sizeof(char *) * ((*count)+1)); + argv = (char **)calloc(sizeof(char *), ((*count)+1)); argv[0] = calloc(261, 1); GetModuleFileNameA(_DWInstance, argv[0], 260); @@ -499,20 +506,6 @@ return argv; } -/* Ok this is a really big hack but what the hell ;) */ -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -{ - char **argv; - int argc; - - _DWInstance = hInstance; - - argv = _convertargs(&argc, lpCmdLine); - - return main(argc, argv); -} -#endif - #ifdef UNICODE /* Macro and internal function to convert UTF8 to Unicode wide characters */ #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL)