dmd.root.rmem
    Allocate memory using malloc or the GC depending on the configuration.
  
License
Source: root/rmem.d
Documentation: https://dlang.org/phobos/dmd_root_rmem.html
- 
  Declarationpure nothrow @nogc @trusted void*pureMalloc(size_tsize);
 pure nothrow @nogc @trusted void*pureCalloc(size_tnmemb, size_tsize);
 pure nothrow @nogc @system void*pureRealloc(void*ptr, size_tsize);
 pure nothrow @nogc @system voidpureFree(void*ptr);Pure variants of C's memory allocation functions malloc,calloc, andreallocand deallocation functionfree.DiscussionUNIX 98 requires that errno be set to ENOMEM upon failure. https://linux.die.net/man/3/malloc However, this is irrelevant for DMD's purposes, and best practice protocol for using errno is to treat it as an outparameter, and not something with state that can be relied on across function calls. So, we'll ignore it.See AlsoD's rules for purity, which allow for memory allocation under specific circumstances. 
- 
  Declarationpure nothrow char[]xarraydup(const(char)[]s);Makes a null-terminated copy of the given string on newly allocated memory. Thenull-terminator won't be part of the returned string slice. It will be at positionnwherenis the length of the input string.Parametersconst(char)[]sstring to copy Return ValueA null-terminated copy of the input array.Examples- auto s1 = "foo"; auto s2 = s1.xarraydup; s2[0] = 'b'; assert(s1 == "foo"); assert(s2 == "boo"); assert(*(s2.ptr + s2.length) == '\0'); string sEmpty; assert(sEmpty.xarraydup is null);
 
- 
  Declarationpure nothrow T[]arraydup(T)(scope const T[]s);Makes a copy of the given array on newly allocated memory. ParametersT[]sarray to copy Return ValueA copy of the input array. Examples- auto s1 = [0, 1, 2]; auto s2 = s1.arraydup; s2[0] = 4; assert(s1 == [0, 1, 2]); assert(s2 == [4, 1, 2]); string sEmpty; assert(sEmpty.arraydup is null);