xrealloc

Uses pureRealloc to realloc a block of memory and throws an outOfMemoryError if the memory cannot be allocated.

  1. void[] xrealloc(void* ptr, size_t size)
    pure nothrow @trusted @nogc
    void[]
    xrealloc
    (
    void* ptr
    ,
    size_t size
    )
  2. void[] xrealloc(T[] buffer, size_t size)

Examples

t {

	void[] buffer = xmalloc(12);
	assert(buffer.length == 12);

	// allocate
	buffer = xrealloc(buffer.ptr, 100);
	assert(buffer.length == 100);

	// deallocate
	buffer = xrealloc(buffer, 10);
	assert(buffer.length == 10)

Meta