tryReallocate

Requests resize of a properly aligned block of memory allocated from allocator or if ptr is null requests memory allocation like allocate/tryAllocate. Memory may be moved, but array elements content will stay the same.

If initialize is true and array.length < newCount the memory of "rest" elements will be set to T.init.

If reallocation fails array isn't changed. tryReallocate returns whether reallocation succeeded.

If reallocation fails reallocate will also call $(COREREF exception, onOutOfMemoryError) which is expected to throw an $(COREREF exception, OutOfMemoryError).

Preconditions: newCount

  1. void reallocate(A allocator, T[] array, size_t newCount, bool initialize, bool gcScan)
  2. bool tryReallocate(A allocator, T[] array, size_t newCount, bool initialize, bool gcScan)
    bool
    tryReallocate
    (
    T
    A
    )
    (
    ref A allocator
    ,
    ref T[] array
    ,
    in size_t newCount
    ,
    in bool initialize = true
    ,
    in bool gcScan = hasIndirections!T
    )

Meta