win32 api - MultiByteToWideChar and WideCharToMultiByte question
Вопрос
Do I need to free the strings I get from those functions? Or maybe the system keeps track of them. Same question goes for GetCommandLine().
Решение
You are responsible for allocation and deallocation of the buffers sent to MultiByteToWideChar
and WideCharToMultiByte
.
The return value from GetCommandLine
is handled by Win32.
Другие советы
For the Unicode conversion functions you need to allocate memory to hold the converted strings. You are in charge of the lifetime of this memory.
For GetCommandLine you don't need to free the returned block of memory.
A very basic rule of thumb is that you have to deallocate if and only if you allocated the memory.
Не связан с StackOverflow