What can you "new"
Daniel Keep
daniel.keep.lists at gmail.com
Wed Mar 25 05:33:05 PDT 2009
bearophile wrote:
> Daniel Keep:
>> I thought "Ha! I have a block allocator mixin for just this purpose!"
>
> Some of similar stuff may be fit to be added to Phobos too :-)
> (Because the std lib is supposed to partially help use the powers of a language).
>
> Bye,
> bearophile
Well, the only ones I ever found a use for were block and free list
allocators. Although I suppose any of the following would be "nice to
have"s:
* Block allocator: pre-allocate space for N instances of a class
(optionally with a specified amount of extra space for subclasses).
Optional growing of the heap.
* Free list allocator: allocate on heap, but save collected instances
for re-use.
* Malloc allocator: wrap malloc/free. This is REALLY dangerous until we
get the ability to tell whether a class was deterministically destroyed
(via delete or scoped destruction) or non-deterministically (GC'ed). Oh
how I've wanted this over the years...
* Function allocation: new takes a pair of functions: a custom
malloc/free pair.
* Placement: new takes a pointer and optionally a free function.
I can't think of any other general allocators aside from those.
-- Daniel
More information about the Digitalmars-d
mailing list