Repository navigation
Conversation
A fixed size buffer that runs out of space now reports it and keeps its existing contents: - Allocate, Realloc, SetString, AllocateMainMessage and NewMessage return nullptr, AllocateString returns an empty span, and AllocateMetadata, VectorPush, VectorReserve and VectorResize return false. - The magic word records the failure in kAllocationFailedFlag, reported by AllocationFailed(). IsValidMagic and IsMoveable ignore the flag, and readers that check the magic with kBitMapMask see the buffer as invalid. - A small block that has no room for a new bitmap run comes from the free list, so small fixed buffers can use all of their space. - VectorResize sets the elements it adds to zero. Previously reserved capacity and elements removed by shrinking kept stale values.
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.
Summary
A fixed size
PayloadBufferthat runs out of space now reports the failure and keeps its existing contents. Phaser uses this to build messages in caller-provided buffers without writing past their end.Allocate,Realloc,SetString,AllocateMainMessageandNewMessagereturnnullptr.AllocateStringreturns an empty span.AllocateMetadata,VectorPush,VectorReserveandVectorResizereturnfalse.kAllocationFailedFlag, whichAllocationFailed()reports.IsValidMagicandIsMoveableignore the flag. Readers that check the magic withkBitMapMasksee the buffer as invalid.VectorResizesets the elements it adds to zero. Before this change, previously reserved capacity and elements removed by shrinking kept stale values.Version 2.1.6.
Testing
bazelisk test //...: all tests pass, including newpayload_buffer_testcases for exhausted buffers, the free-list fallback (SmallBlockUsesFreeListWhenRunDoesNotFit) and zeroing on resize (VectorResizeZeroesNewElements).