Skip to content

Fix Array TrimExcess condition#2421

Open
cuiweixie wants to merge 1 commit intobeefytech:masterfrom
cuiweixie:fix/array-trimexcess-condition
Open

Fix Array TrimExcess condition#2421
cuiweixie wants to merge 1 commit intobeefytech:masterfrom
cuiweixie:fix/array-trimexcess-condition

Conversation

@cuiweixie
Copy link
Copy Markdown

Summary

TrimExcess() used mSize > mAllocSize, which does not occur for a consistent array (allocated capacity should be at least the used length). The intended check is to shrink when there is spare capacity: mSize < mAllocSize.

Change

  • BeefySysLib/util/Array.h: correct the condition so excess storage is actually released when appropriate.

TrimExcess should shrink the buffer when allocated capacity exceeds the
logical size (mSize < mAllocSize). The previous comparison never held in
valid states.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant