3 ms·
"Using a language like C#, Javascript, or Python would force that allocation structure." No. C# structs are C structs. Shape[], Span<Shape> or Shape* would not
by neonsunset 3y ago
"Using a language like C#, Javascript, or Python would force that allocation structure."
No. C# structs are C structs. Shape[], Span<Shape> or Shape* would not be an array of pointers. Any of the following would work:
var fromHeap = new Shape[100];
var fromStack = (stackalloc Shape[100]);
var fromPool = ArrayPool<Shape>.Shared.Rent(100);
var fromMalloc = (Shape*)NativeMemory.Alloc(sizeof(Shape) * 100);