xrealloc

Reallocates the given array using a new size.

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

Examples

t {

	ubyte[] bytes = cast(ubyte[])xmalloc(12);
	xrealloc(bytes, 44); // same as `xrealloc(bytes.ptr, 44)`
	assert(bytes.length == 44);

	int[] ints = cast(int[])xcalloc(3, 4);
	assert(ints.length == 3);
	xrealloc(ints, 4); // same as `xrealloc(ints.ptr, 4 * 4)`
	assert(ints.length == 4)

Meta