alloc_atomic allocates an element of the right type and with the right amount of memory. It does so by examining the type that it must return. A
nativeClassId is a GUID which is 16 bytes (128 bits), so this invocation will 16 bytes.
alloc_array will allocate a piece of memory to hold an array containing
Count values of the type in question. I.e.
Count is not a memory size, but a
count of elements.
These predicates works for structs (functors domains with a single functor) but not for functors domains with several alternatives, because such alternatives may have different size. Likewise they cannot allocate memory for a string, because it cannot guess how large a string you want.
In older code you may see:
Code: Select all
CLSID = uncheckedConvert(comDomains::nativeClassId, memory::allocAllocateAtomic(sizeOfDomain(comDomains::nativeClassId))),
So this "magic" is a lot easier to write.
alloc_array would correspond to code like this
Code: Select all
CLSIDArray = uncheckedConvert(comDomains::nativeClassId,
memory::allocAllocateAtomic(Count * sizeOfDomain(comDomains::nativeClassId))),