DIP 1021--Argument Ownership and Function Calls--Community Review Round 1

Nick Treleaven nick at geany.org
Fri Jul 19 13:12:04 UTC 2019


On Friday, 19 July 2019 at 13:09:29 UTC, Nick Treleaven wrote:
>     void append(int e) @trusted
>     {   // inefficient but it works
>         const len = data.length + 1;
>         auto ptr = cast(int*)realloc(data.ptr, len * 
> int.sizeof);
>         data = ptr[0..len];
>     }

Oops, forgot last line:

         data[$-1] = e;



More information about the Digitalmars-d mailing list