Allocating a wstring on the stack (no GC)?
Maxime Chevalier-Boisvert via Digitalmars-d
digitalmars-d at puremagic.com
Wed May 7 12:03:36 PDT 2014
> This is named slicing. You can also slice a
> global/static/__gshared buffer.
> alloca returns a void*, then you can cast it to the pointer
> type you want, and then you slice the pointer:
>
> auto ptr = cast(wchar*)alloca(wchar.sizeof * len);
> if (ptr == null) throw new Error("...");
> auto mySlice = ptr[0 .. len];
Is the slice going to be allocated on the stack? (I imagine the
answer is yes)
Thanks for your help Mr Bear.
More information about the Digitalmars-d
mailing list