TempAlloc Overhaul

bearophile bearophileHUGS at lycos.com
Sat Jun 11 16:04:24 PDT 2011


dsimcha:

> I've overhauled my TempAlloc proposal based on some of the suggestions I've received.

It's improved :-)


>3.  Make alignedMalloc and friends private for now, again to make the proposal more tightly focused.<

They are useful so I'd like such alignedCMalloc / free to be generally visible, with a template argument to specify the desire alignment, that defaults to 16. But I agree it's better to not put it in std.tempalloc.


>The first segment of the TempAlloc stack is allocated lazily, so no space is allocated in any thread that does not use TempAlloc.<

Is this causing any slowdown in the usage of the memory?


>static void* malloc(size_t nbytes);<

I think the docs have to say this is aligned memory (and there is no way to specify a smaller alignment).


>In this case sizes may be specified for any number of dimensions from 1 to the number in T. <

Isn't it bug prone to allow to specify a number of sizes less than the number of dimensions?


> double[] foo = TempAlloc.newArray!(double[])(100);

A little usability problem: an array of array of double or just array of double?

Bye,
bearophile


More information about the Digitalmars-d mailing list