View source code
Display the source code in dmd/root/rmem.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function dmd.root.rmem.xarraydup
Makes a null-terminated copy of the given string on newly allocated memory.
The null-terminator won't be part of the returned string slice. It will be
at position n
where n
is the length of the input string.
char[] xarraydup
(
const(char)[] s
);
Parameters
Name | Description |
---|---|
s | string to copy |
Returns
A null-terminated copy of the input array.
Example
auto s1 = "foo";
auto s2 = s1 .xarraydup;
s2[0] = 'b';
writeln(s1); // "foo"
writeln(s2); // "boo"
writeln(*(s2 .ptr + s2 .length)); // '\0'
string sEmpty;
assert(sEmpty .xarraydup is null);
Authors
Walter Bright, http://www.digitalmars.com
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.