英語版
このページの英語版を見る
dmd.root.rmem
malloc またはGCを使用して、構成に応じてメモリを割り当てる。
Authors:
Walter Bright, https://www.digitalmars.com
License:
ソースroot/rmem.d
適用範囲 https://codecov.io/gh/dlang/dmd/src/master/src/dmd/root/rmem.d
- pure 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
); - Cのメモリ割り当て関数の純粋なバリアントであるmalloc 、calloc 、およびrealloc 、およびメモリ解放関数であるfree 。UNIX 98では、エラー発生時には errno を ENOMEM に設定することが求められる。 https://linux.die.net/man/3/malloc しかし、これはDMDの目的とは無関係であり、 errno の使用に関するベストプラクティスは、out パラメータとして扱うことであり、 関数呼び出し全体で信頼できる状態を持つものではない。 そのため、無視することにする。 "function"関数See Also:Dの純粋性のルールでは、 特定の状況下でのメモリ割り当てが許可されている。
- pure nothrow char[]
xarraydup
(scope const(char)[]s
); - 新たに割り当てられたメモリ上に、与えられた文字列のヌル文字で終端するコピーを作成する。 ヌル文字は、返される文字列には含まれない。n の位置にあり、n は入力文字列の長さである。Parameters:
const(char)[] s
コピーする文字列 Returns: 入力配列のヌル文字で終端するコピー。null-terminatednull-terminated入力配列のヌル文字で終端するコピー。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
); - 新たに割り当てられたメモリ上に、指定された配列のコピーを作成する。Parameters:
T[] s
コピーする配列 Returns: 入力配列のコピー。arrayarray入力配列のコピー。Examples:arrayarrayauto 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-2024 by the D Language Foundation
DEEPL APIにより翻訳、ところどころ修正。
このページの最新版(英語)
このページの原文(英語)
翻訳時のdmdのバージョン: 2.109.1
ドキュメントのdmdのバージョン: 2.109.1
翻訳日付 :
HTML生成日時:
編集者: dokutoku