Allocating byte aligned array
timvol
timvol at unknownmailaddress.com
Wed Sep 27 21:39:41 UTC 2017
Hi guys,
how can I allocate an (e.g. 16) byte aligned array?
In C I can do the following:
void *mem = malloc(1024+15);
void *ptr = ((uintptr_t)mem+15) & ~ (uintptr_t)0x0F;
memset_16aligned(ptr, 0, 1024);
free(mem);
I think in D it looks similar to this:
auto mem = new ubyte[1024+15];
auto ptr = (mem.ptr + 15) & ~ (...???...) 0x0F;
How to fill ...???... ?
Without a cast, the compiler tells me that I the types are
incompatible (ubyte* and int).
What's the correct syntax here?
PS: I don't want to use the experimental branch that provides
alignedAllocate().
More information about the Digitalmars-d-learn
mailing list