pwstrBuffer method

PWSTR pwstrBuffer([
  1. int length = 1
])

Allocates a mutable UTF-16 string buffer (PWSTR) with capacity for length UTF-16 code units, including the terminating NUL character.

This is intended for Win32 APIs that write UTF-16 strings into caller-provided buffers.

The buffer is owned by the arena and freed automatically when the arena is disposed.

Example:

using((arena) {
  final buffer = arena.pwstrBuffer(260);
  GetModuleFileName(NULL, buffer, 260);
});

Implementation

PWSTR pwstrBuffer([int length = 1]) =>
    .new(allocate<WCHAR>(length * 2).cast());