GC.shrinkArrayUsed
bool shrinkArrayUsed(void[] slice, size_t existingUsed, bool atomic = false) nothrow;Shrink used space of a slice in place.
Unlike the other array functions, the array slice passed in is the target slice, and the existing used space is passed separately. This is to discourage code that ends up with a slice to dangling valid data.
If slice.ptr[0 .. existingUsed] does not point to the end of a valid GC appendable slice, then the operation fails.
Parameters
slice | The proposed valid slice data. |
existingUsed | The amount of data in the block (starting at slice.ptr) that is currently valid in the array. If this amount does not match the current used size, the operation fails. |
atomic | The slice may be shared between threads, and the operation should be atomic. |
Returns
true if successful.