@safe @nogc memory allocation

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 28 12:43:52 PDT 2014


I would like my radix sort function radixSortImpl() at

https://github.com/nordlow/justd/blob/master/intsort.d

to not use the GC. However, when I tag with @nogc I get the error:

intsort.d(195,47): Error: @nogc function 
'isort.radixSortImpl!(byte[], "a", false).radixSortImpl' cannot 
call non- at nogc function 'std.array.uninitializedArray!(byte[], 
immutable(ulong)).uninitializedArray'

Is there an alternative to

std.array: uninitializedArray
Elem[] y = uninitializedArray!(Elem[])(n);

that neither use the GC and nor preinitialize the data?

Could the recent DMD pull optimization to scope here

https://github.com/D-Programming-Language/dmd/commit/abc7033bf9cf7f7224a47e45096efc48a21b5ab8

be used?

/Per


More information about the Digitalmars-d-learn mailing list