Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Calendar
  - Forums
  - IRC
  - Wiki
  - GitHub
  - Issues
  - Get involved
  - Contributors
  - Foundation
  - Security Team
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - run.dlang.io
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
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 a local clone.

# dmd.root.rmem

Compiler implementation of the D programming language http://dlang.org
Authors:
Walter Bright, http://www.digitalmars.com
License:
Boost License 1.0

Source root/rmem.d

Documentation https://dlang.org/phobos/dmd_root_rmem.html

Coverage https://codecov.io/gh/dlang/dmd/src/master/src/dmd/root/rmem.d

pure nothrow char[] `xarraydup`(const(char)[] `s`);
  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.
  Parameters:

  const(char)[] `s` | string to copy

  Returns:
  A 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);

pure nothrow T[] `arraydup`(T)(scope const T[] `s`);
  Makes a copy of the given array on newly allocated memory.
  Parameters:

  T[] `s` | array to copy

  Returns:
  A 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);

Copyright © 1999-2019 by the D Language Foundation | Page generated by Ddoc on Sun Aug 4 14:34:43 2019