英語版
このページの英語版を見る
std.experimental.allocator.mallocator
C のヒープアロケータ。
- struct
Mallocator
; - Cのヒープアロケータ。Examples:
auto buffer = Mallocator.instance.allocate(1024 * 1024 * 4); scope(exit) Mallocator.instance.deallocate(buffer); //...
- enum uint
alignment
; - アラインメントはplatformAlignment に等しい静的定数である。 に等しい静的定数であり、どのDデータ型に対しても適切なアライメントを保証する。
- shared const pure nothrow @nogc @trusted void[]
allocate
(size_tbytes
);
shared const pure nothrow @nogc @system booldeallocate
(void[]b
);
shared const pure nothrow @nogc @system boolreallocate
(ref void[]b
, size_ts
); - 上記で定義されたセマンティクスに従った標準的なアロケータ・メソッドである。この
deallocate
とreallocate
メソッドは@system 。 メソッドはメモリを移動させ、ユーザーコードにぶら下がりポインタを残す可能性があるからだ。やや逆説的だが 逆説的だが、malloc は@safe 、割り当てられたメモリをリークする余裕のある安全なプログラムにしか役に立たない。 にしか役に立たない。 - static shared Mallocator
instance
; - このアロケータ型のグローバル・インスタンスを返す。Cのヒープアロケータは スレッドセーフであるため、そのすべてのメソッドとit " 自体は shared.
- struct
AlignedMallocator
; - OS固有のプリミティブを使用し、統一されたAPIの下で整列されたアロケータ。Examples:
auto buffer = AlignedMallocator.instance.alignedAllocate(1024 * 1024 * 4, 128); scope(exit) AlignedMallocator.instance.deallocate(buffer); //...
- enum uint
alignment
; - デフォルトのアライメントはplatformAlignment である。
- shared nothrow @nogc @trusted void[]
allocate
(size_tbytes
); - alignedAllocate(bytes, platformAlignment) に転送する。
- shared nothrow @nogc @trusted void[]
alignedAllocate
(size_tbytes
, uinta
); - 使用方法 posix_memalignを使用する。 __aligned_mallocで使用する。
- shared nothrow @nogc @system bool
deallocate
(void[]b
); - 呼び出し free(
b
.ptr)を呼び出す。 __aligned_free(b
.ptr)を呼び出す。 - shared nothrow @nogc @system bool
reallocate
(ref void[]b
, size_tnewSize
);
shared nothrow @nogc @system boolalignedReallocate
(ref void[]b
, size_ts
, uinta
); - alignedReallocate(b, newSize, platformAlignment) に転送する。 allocate 。そうしないと、 で渡されたカスタムアライメントが失われる可能性がある。 alignedAllocate アラインメントが失われる可能性がある。
- static shared AlignedMallocator
instance
; - このアロケータ型のグローバルインスタンスを返す。Cのヒープアロケータは スレッドセーフなので、すべてのメソッドと
instance
自身は shared.
Copyright © 1999-2024 by the D Language Foundation
DEEPL APIにより翻訳、ところどころ修正。
このページの最新版(英語)
このページの原文(英語)
翻訳時のdmdのバージョン: 2.108.0
ドキュメントのdmdのバージョン: 2.109.1
翻訳日付 :
HTML生成日時:
編集者: dokutoku