wsalloc function
Allocates a mutable UTF-16 string buffer (PWSTR) with capacity for
length UTF-16 code units, including the terminating NUL character.
The returned pointer must be freed using free, unless allocated through
an Arena.
This is intended for Win32 APIs that write UTF-16 strings into caller-provided buffers.
Example:
final buffer = wsalloc(260);
GetModuleFileName(NULL, buffer, 260);
free(buffer);
Implementation
PWSTR wsalloc([int length = 1, Allocator allocator = adaptiveCalloc]) =>
PWSTR(allocator<WCHAR>(length * 2).cast());