allow on stack with betterC
test
test at gmail.com
Tue Oct 23 10:18:56 UTC 2018
On Tuesday, 23 October 2018 at 07:59:53 UTC, Dennis wrote:
> On Tuesday, 23 October 2018 at 05:36:00 UTC, test wrote:
>> correct if I am wrong, I think malloc is on heap and is very
>> slow.
>
> Yes, you probably want a static array on the stack:
>
> ```
> scope ubyte[4] tmp = void; // or a default value
> ```
>
> This is analogous to this C (except scope):
> ```
> unsigned char tmp[4];
> ```
>
> While 'new' is analogous to 'malloc'.
I can not user static array because the length is a runtime vars.
More information about the Digitalmars-d-learn
mailing list