On Sunday, 7 June 2015 at 16:25:29 UTC, Oleg B wrote:
auto myalloc(T)( size_t count ) { struct Impl{ size_t len; void* ptr; } union Wrap { Impl impl; T[] arr; }auto ret = Wrap( Impl( count, calloc( count, T.sizeof ) ) ).arr;enforce( ret.ptr !is null ); return ret; }
Note that you can slice non-gc memory. `Impl` is basically what a slice is internally.
auto ret = calloc(count, T.sizeof)[0..(count*T.sizeof)]