Is it possible to assumeSafeAppend malloced memory?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 19 12:14:09 PDT 2014


On Mon, 19 May 2014 14:46:59 -0400, monarch_dodra <monarchdodra at gmail.com>  
wrote:

> 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.

Yes, I understand. When allocating an array, you need to initialize the  
array properly, and the standard library should not have the  
implementation details of the array management leaked into it. I think you  
can replace the GC.malloc call with the new one you mentioned, no?

It's still a bug. The expectation of array(x, y, z) is that it's the same  
as [x, y, z]. That is not true currently.

-Steve


More information about the Digitalmars-d-learn mailing list