Вопрос

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top