Skip to content

Commit

Permalink
Fix typo (phil-opp#927)
Browse files Browse the repository at this point in the history
`ListNone::new` to `ListNode::new`
  • Loading branch information
16yuki0702 authored Feb 8, 2021
1 parent d4034ee commit 16cc704
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion blog/content/edition-2/posts/11-allocator-designs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ impl LinkedListAllocator {
}
```

The struct contains a `head` node that points to the first heap region. We are only interested in the value of the `next` pointer, so we set the `size` to 0 in the `ListNone::new` function. Making `head` a `ListNode` instead of just a `&'static mut ListNode` has the advantage that the implementation of the `alloc` method will be simpler.
The struct contains a `head` node that points to the first heap region. We are only interested in the value of the `next` pointer, so we set the `size` to 0 in the `ListNode::new` function. Making `head` a `ListNode` instead of just a `&'static mut ListNode` has the advantage that the implementation of the `alloc` method will be simpler.

Like for the bump allocator, the `new` function doesn't initialize the allocator with the heap bounds. In addition to maintaining API compatibility, the reason is that the initialization routine requires to write a node to the heap memory, which can only happen at runtime. The `new` function, however, needs to be a [`const` function] that can be evaluated at compile time, because it will be used for initializing the `ALLOCATOR` static. For this reason, we again provide a separate, non-constant `init` method.

Expand Down

0 comments on commit 16cc704

Please sign in to comment.