سؤال

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