mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-23 04:52:42 -08:00
adjust memory allocation functions in windows API ecl_get_commandline_args.
the caller and the callee maybe use difference compiler and settings.
This commit is contained in:
parent
040ec49138
commit
52a232b2d1
2 changed files with 7 additions and 2 deletions
|
|
@ -939,6 +939,7 @@ si_pointer(cl_object x)
|
|||
#if defined(ECL_MS_WINDOWS_HOST)
|
||||
void
|
||||
ecl_get_commandline_args(int* argc, char*** argv) {
|
||||
/* the caller should use LocalFree to release the memory of strings in argv and argv itself */
|
||||
LPWSTR *wArgs;
|
||||
int i;
|
||||
|
||||
|
|
@ -946,10 +947,10 @@ ecl_get_commandline_args(int* argc, char*** argv) {
|
|||
return;
|
||||
|
||||
wArgs = CommandLineToArgvW(GetCommandLineW(), argc);
|
||||
*argv = (char**)malloc(sizeof(char*)*(*argc));
|
||||
*argv = (char**)LocalAlloc(0, sizeof(char*)*(*argc));
|
||||
for (i=0; i<*argc; i++) {
|
||||
int len = wcslen(wArgs[i]);
|
||||
(*argv)[i] = (char*)malloc(2*(len+1));
|
||||
(*argv)[i] = (char*)LocalAlloc(0, 2*(len+1));
|
||||
wcstombs((*argv)[i], wArgs[i], len+1);
|
||||
}
|
||||
LocalFree(wArgs);
|
||||
|
|
|
|||
|
|
@ -333,6 +333,10 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdS
|
|||
~A
|
||||
} ECL_CATCH_ALL_END;
|
||||
si_exit(0);
|
||||
for (int i = 0; i < argc; i++) {
|
||||
LocalFree(argv[i]);
|
||||
}
|
||||
LocalFree(argv);
|
||||
}
|
||||
")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue