allocate array with new
    Jonathan M Davis 
    jmdavisProg at gmx.com
       
    Wed May 16 14:12:58 PDT 2012
    
    
  
On Wednesday, May 16, 2012 12:05:02 H. S. Teoh wrote:
> It would be nice if there was an easy way of switching allocators, so
> that you can, for example, indicate that all allocations done inside a
> particular function should use malloc/free (including, say, AA's,
> arrays, etc.), and have the runtime automatically switch back to the GC
> on scope exit.
Once we have custom allocators, that should be easy enough as long as you 
passing the allocator around. But new will always use the GC, and malloc will 
always do what it does in C (it _is_ the C function after all), so anything 
you want in terms of custom allocation is going to have to go through custom 
allocator objects. However, since the custom allocators are going to be 
runtime entities (rather than having classes templated on their allocators 
like the STL does), it would be easy enough to choose the appropriate 
allocator at runtime and have each function use a different allocator if it so 
chooses.
- Jonathan M Davis
    
    
More information about the Digitalmars-d-learn
mailing list