Skip to content

Commit 8ea15d1

Browse files
committed
add space to markdown
1 parent 7ca878c commit 8ea15d1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

1.6/ja/book/custom-allocators.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<!-- out the default global allocator in use at compile time. The design is currently -->
88
<!-- spelled out in [RFC 1183][rfc] but this will walk you through how to get your -->
99
<!-- own allocator up and running. -->
10-
メモリ割り当てが常に簡単に出来るとは限りません。ほとんどの場合、Rustが既定の方法でメモリ割り当てを行いますが、割り当て方法をカスタマイズする必要が出てくる場合があります。現在、コンパイラと標準ライブラリはコンパイル時に既定のグローバルアロケータを切り替えることが出来ます。詳細は[RFC 1183][rfc]に書かれていますが、ここではどのように独自のアロケータを作成するか順を追って説明します。
10+
メモリ割り当てが常に簡単に出来るとは限りません。ほとんどの場合、Rustが既定の方法でメモリ割り当てを行いますが、割り当て方法をカスタマイズする必要が出てくる場合があります。現在、コンパイラと標準ライブラリはコンパイル時に既定のグローバルアロケータを切り替えることが出来ます。詳細は [RFC 1183][rfc] に書かれていますが、ここではどのように独自のアロケータを作成するか順を追って説明します。
1111

1212
[rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1183-swap-out-jemalloc.md
1313

@@ -21,20 +21,20 @@
2121
<!-- allocate and deallocate memory. The standard library is not compiled assuming -->
2222
<!-- either one, and the compiler will decide which allocator is in use at -->
2323
<!-- compile-time depending on the type of output artifact being produced. -->
24-
現在コンパイラは`alloc_system``alloc_jemalloc`(いくつかのターゲットにはありません)という2つの既定のアロケータを提供しています。これらのアロケータは単に普通のRustのクレートで、メモリの割り当てと解放の手続きを実装しています。標準ライブラリはどちらか一方を前提としてコンパイルされているわけではありません。コンパイラは生成する成果物の種類に応じてどちらのアロケータを使用するかをコンパイル時に決定します。
24+
現在コンパイラは `alloc_system``alloc_jemalloc` (いくつかのターゲットにはありません)という2つの既定のアロケータを提供しています。これらのアロケータは単に普通のRustのクレートで、メモリの割り当てと解放の手続きを実装しています。標準ライブラリはどちらか一方を前提としてコンパイルされているわけではありません。コンパイラは生成する成果物の種類に応じてどちらのアロケータを使用するかをコンパイル時に決定します。
2525

2626
<!-- Binaries generated by the compiler will use `alloc_jemalloc` by default (where -->
2727
<!-- available). In this situation the compiler "controls the world" in the sense of -->
2828
<!-- it has power over the final link. Primarily this means that the allocator -->
2929
<!-- decision can be left up the compiler. -->
30-
バイナリを生成する場合、既定では(もし可能なら)`alloc_jemalloc`を使用します。この場合、コンパイラは最後のリンクにまで影響力を持っているという意味で、「全世界を支配」しています。従ってアロケータの選択はコンパイラに委ねることができます。
30+
バイナリを生成する場合、既定では(もし可能なら) `alloc_jemalloc` を使用します。この場合、コンパイラは最後のリンクにまで影響力を持っているという意味で、「全世界を支配」しています。従ってアロケータの選択はコンパイラに委ねることができます。
3131

3232
<!-- Dynamic and static libraries, however, will use `alloc_system` by default. Here -->
3333
<!-- Rust is typically a 'guest' in another application or another world where it -->
3434
<!-- cannot authoritatively decide what allocator is in use. As a result it resorts -->
3535
<!-- back to the standard APIs (e.g. `malloc` and `free`) for acquiring and releasing -->
3636
<!-- memory. -->
37-
一方、動的あるいは静的ライブラリの場合、既定では`alloc_system`を使用します。他のアプリケーションや他の環境など、使用するアロケータの決定権がない世界において、Rustは「お客」に過ぎません。そのため、メモリの割り当てと解放を行うには、標準API(例えば`malloc``free`)に頼ることになります。
37+
一方、動的あるいは静的ライブラリの場合、既定では `alloc_system` を使用します。他のアプリケーションや他の環境など、使用するアロケータの決定権がない世界において、Rustは「お客」に過ぎません。そのため、メモリの割り当てと解放を行うには、標準API(例えば `malloc``free` )に頼ることになります。
3838

3939
<!-- # Switching Allocators -->
4040
# アロケータの切り替え
@@ -84,7 +84,7 @@ pub fn foo() {
8484
<!-- crate which implements the allocator API (e.g. the same as `alloc_system` or -->
8585
<!-- `alloc_jemalloc`). As an example, let's take a look at a simplified and -->
8686
<!-- annotated version of `alloc_system` -->
87-
時々jemallocとシステムアロケータの選択では足りず、全く新しいカスタムアロケータが必要になることがあります。この場合、アロケータAPI(例えば`alloc_system``alloc_jemalloc`と同様のもの)を実装した独自のクレートを書くことになります。例として、`alloc_system`の簡素な注釈付きバージョンを見てみましょう。
87+
時々jemallocとシステムアロケータの選択では足りず、全く新しいカスタムアロケータが必要になることがあります。この場合、アロケータAPI(例えば `alloc_system``alloc_jemalloc` と同様のもの)を実装した独自のクレートを書くことになります。例として、 `alloc_system` の簡素な注釈付きバージョンを見てみましょう。
8888

8989
```rust,no_run
9090
# // only needed for rustdoc --test down below
@@ -115,7 +115,7 @@ pub fn foo() {
115115
// this specifically requires the in-tree version.
116116
// この独自アロケータはFFIバインディングのためにin-treeのlibcクレートを使います。
117117
// 注記: 現在の外部libc(crate.ioのもの)は標準ライブラリとリンクしているため使用できません
118-
// (`#![no_std]`がまだstableではないためです)。そのため特別にin-treeのlibcが必要になります。
118+
// ( `#![no_std]` がまだstableではないためです)。そのため特別にin-treeのlibcが必要になります。
119119
#![feature(libc)]
120120
121121
#[no_mangle]
@@ -188,4 +188,4 @@ fn main() {
188188
<!-- depend on a crate which needs an allocator (e.g. circular dependencies are not -->
189189
<!-- allowed). This basically means that allocators must restrict themselves to -->
190190
<!-- libcore currently. -->
191-
* アロケータを使うコードは`#![needs_allocator]`でタグ付けされます(例えば現時点での`liballoc`クレート)。また、`#[allocator]`がついたクレートはアロケータを使うクレートに依存することが出来ません(循環依存は許されていません)。このためアロケータは原則としてlibcoreにしか依存しないようにする必要があります。
191+
* アロケータを使うコードは `#![needs_allocator]` でタグ付けされます(例えば現時点での `liballoc` クレート)。また、 `#[allocator]` がついたクレートはアロケータを使うクレートに依存することが出来ません(循環依存は許されていません)。このためアロケータは原則としてlibcoreにしか依存しないようにする必要があります。

0 commit comments

Comments
 (0)