Remove warning from docs for withUnsafeTemporaryAllocation() about overallocation.#89467
Open
grynspan wants to merge 1 commit into
Open
Remove warning from docs for withUnsafeTemporaryAllocation() about overallocation.#89467grynspan wants to merge 1 commit into
withUnsafeTemporaryAllocation() about overallocation.#89467grynspan wants to merge 1 commit into
Conversation
…overallocation. The markup for the two overloads of `withUnsafeTemporaryAllocation()` states: > The implementation may allocate a larger buffer pointer than is strictly > necessary to contain `capacity` values of type `type`. The behavior of a > program that attempts to access any such additional storage is undefined. This text is meant to indicate that the compiler, runtime, OS, etc. are free to allocate a larger buffer, which may occur e.g. if you ask for 1 byte and the generated assembly pushes `SP` up by 4/8 instead, or if you ask for 1025 bytes and the OS's `malloc()` gives you a 4KB/16KB page back. It does not imply that the buffer created and passed to `body` has a bad `count` value or is otherwise unsound. This text has proven confusing as it sounds scarier than it is meant to be. It is just meant to document that the system can and does overallocate. I'm just going to remove it; there is no way for a well-formed program to access any such excess bytes, and this API is already marked unsafe so if you decide to read off the end of the buffer, you've sealed your own fate anyway.
Contributor
Author
|
@swift-ci smoke test |
Contributor
Author
|
@swift-ci test Windows |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The markup for the two overloads of
withUnsafeTemporaryAllocation()states:This text is meant to indicate that the compiler, runtime, OS, etc. are free to allocate a larger buffer, which may occur e.g. if you ask for 1 byte and the generated assembly pushes
SPup by 4/8 instead, or if you ask for 1025 bytes and the OS'smalloc()gives you a 4KB/16KB page back. It does not imply that the buffer created and passed tobodyhas a badcountvalue or is otherwise unsound.This text has proven confusing as it sounds scarier than it is meant to be. It is just meant to document that the system can and does overallocate. I'm just going to remove it; there is no way for a well-formed program to access any such excess bytes, and this API is already marked unsafe so if you decide to read off the end of the buffer, you've sealed your own fate anyway.