Allocating a wstring on the stack (no GC)?

Maxime Chevalier-Boisvert via Digitalmars-d digitalmars-d at puremagic.com
Wed May 7 11:41:16 PDT 2014


> Unless I'm misunderstanding it should be as simple as:
>
> wchar[100] stackws; // alloca() if you need it to be 
> dynamically sized.
>
> A slice of this static array behaves just like a slice of a 
> dynamic array.

I do need it to be dynamically sized. I also want to avoid 
copying my string data if possible. Basically, I just want to 
create a wstring "view" on an existing "raw" buffer that exists 
in memory somewhere, based on a pointer to this buffer and its 
length.

Side note: wouldn't alloca just produce a wchar*, not an array 
(wouldn't have length information)?


More information about the Digitalmars-d mailing list