Is it possible to assumeSafeAppend malloced memory?

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 19 11:46:59 PDT 2014


On Monday, 19 May 2014 at 13:55:00 UTC, Steven Schveighoffer 
wrote:
>> On Monday, 19 May 2014 at 06:08:18 UTC, Ali Çehreli wrote:
>>>
>>> This issue puts std.array.array to a disadvantage compared to 
>>> proper slices because array() involves the following call 
>>> chain, the last of which does call GC.malloc:
>>>
>>>  trustedAllocateArray
>>>  uninitializedArray
>>>  arrayAllocImpl
>
> This is a bug. arrayAllocImpl should alloc using the proper 
> functions and flags.

Well, Yes and no. The issue is that there is no interface 
available to achieve this, that wouldn't completely destroy what 
`array` is going for anyways. So it's more of a design issue than 
a bug proper.

https://issues.dlang.org/show_bug.cgi?id=12444
https://github.com/D-Programming-Language/phobos/pull/2044

The only way I'd know (currently) to make it work, is with 
reserve+assumeSafeAppend. But the issue with that approach is 
that it's not pure (because of the whole purity with global GC 
side effects deal).


More information about the Digitalmars-d-learn mailing list