How to do alligned allocation?

mw mingwu at gmail.com
Fri Sep 30 16:25:27 UTC 2022


On Friday, 30 September 2022 at 16:23:00 UTC, mw wrote:
> On Friday, 30 September 2022 at 15:57:22 UTC, Quirin Schroll 
> wrote:
>> When I do `new void[](n)`, is that buffer allocated with an 
>> alignment of 1 or what are the guarantees? How can I set an 
>> alignment? Also, is the alignment of any type guaranteed to be 
>> a power of 2?
>
> https://dlang.org/library/core/stdc/stdlib/aligned_alloc.html
>
> It's the C func, so check C lib doc.

and then use emplace on the C-alloc-ed memory.


More information about the Digitalmars-d-learn mailing list