Marco Leise wrote: > In D we allocate memory through the GC [...] > Let's assume, we have a program that allocates some buffers in > advance, that it may not use fully. [...] > there is really no alternative to calloc.
1) calloc implements a strategie for allocating memory. If this strategy is usefull for parts of a program, then the GC should be informed from the code and be capable to adapt its behavior to the requested strategy. This seems necessary because there is not only the null pattern to initialize allocated memory. 2) According to your OP the request for allocating memory can be disjoint partitioned into three: a) memory that is guaranteed to be used b) memory that is guaranteed not to be used and c) memory that might be used. For the case that a + b exceeds available memory, should the coder predeclare a strategy, i.e. should the GC signal out of memory on request of the memory or should the GC wait until that sum reaches some deadline? -manfred