-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Add doc comment for Allocator.alignedAlloc() #25930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -248,6 +248,16 @@ pub fn allocSentinel( | |
| return self.allocWithOptionsRetAddr(Elem, n, null, sentinel, @returnAddress()); | ||
| } | ||
|
|
||
| /// Allocates with an alignment which is incorporated into the returned type. | ||
| /// Call `free` when done. | ||
| /// | ||
| /// Prefer inferred types like `const data = alignedAlloc(...)` as it will use | ||
| /// the correctly aligned type. | ||
| /// | ||
| /// Avoid explicit types like `const data: u8[] = alignedAlloc(...)` as they | ||
| /// can change the alignment type information needed when calling `free`. | ||
| /// | ||
| /// If alignment is not comptime known use `rawAlloc` and `rawFree`. | ||
|
||
| pub fn alignedAlloc( | ||
| self: Allocator, | ||
| comptime T: type, | ||
|
|
@@ -432,7 +442,7 @@ pub fn reallocAdvanced( | |
| return mem.bytesAsSlice(T, new_bytes); | ||
| } | ||
|
|
||
| /// Free an array allocated with `alloc`. | ||
| /// Free an array allocated with `alloc` or `alignedAlloc`. | ||
| /// If memory has length 0, free is a no-op. | ||
| /// To free a single item, see `destroy`. | ||
| pub fn free(self: Allocator, memory: anytype) void { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[]u8would be the correct type here,u8[]is invalid.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry, I didn't actually pull the latest version of the comment into this branch. Please take a look again, it has been rewritten.