Skip to content
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

Add available() API in AddressAllocator #94

Closed
wants to merge 17 commits into from
Closed

Conversation

ylzh10
Copy link

@ylzh10 ylzh10 commented Feb 18, 2025

Summary of the PR

bit dumb here, but I thought it should be a common use case to get the rest available memories in AddressAllocator, while i don't see a way on how to get this info today.
Or there is already a way to get this info from allocator and somehow i missed it? (please lmk)

So add a new private var available

  • init it w/ the total memory space size
  • inc/dec it when allocate/free()
  • expose it in a new public API available()

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@ylzh10 ylzh10 marked this pull request as ready for review February 18, 2025 22:29
@roypat
Copy link
Collaborator

roypat commented Feb 19, 2025

Hi! Thanks for your PR :)

Could you tell us a bit more about your usecase for this feature? I'm wondering how this available information could be used, because even address allocations of length L <= available() can fail because of internal fragmentation. What is the upside compare to try trying to called allocate() and seeing if it returned an Err?

Also, please squash all your commits into one, and give that one commit a commit description that outlines the changes, and why they're being done.

Signed-off-by: ylzh10 <[email protected]>

Create rust.yml

Signed-off-by: ylzh10 <[email protected]>

Update CHANGELOG.md

Signed-off-by: ylzh10 <[email protected]>

Update address_allocator.rs

Signed-off-by: ylzh10 <[email protected]>

Update address_allocator.rs

Signed-off-by: ylzh10 <[email protected]>

Update address_allocator.rs

Signed-off-by: ylzh10 <[email protected]>

Update address_allocator.rs

Signed-off-by: ylzh10 <[email protected]>

Update address_allocator.rs

Signed-off-by: ylzh10 <[email protected]>

Update address_allocator.rs

Signed-off-by: ylzh10 <[email protected]>

Update address_allocator.rs

Signed-off-by: ylzh10 <[email protected]>

Update address_allocator.rs

Signed-off-by: ylzh10 <[email protected]>

Delete .github/workflows directory

Signed-off-by: ylzh10 <[email protected]>

Update CHANGELOG.md

Signed-off-by: ylzh10 <[email protected]>

update changelog.md

Signed-off-by: ylzh10 <[email protected]>

update format

Signed-off-by: ylzh10 <[email protected]>
@ylzh10
Copy link
Author

ylzh10 commented Feb 19, 2025

Hi! Thanks for your PR :)

Could you tell us a bit more about your usecase for this feature? I'm wondering how this available information could be used, because even address allocations of length L <= available() can fail because of internal fragmentation. What is the upside compare to try trying to called allocate() and seeing if it returned an Err?

Also, please squash all your commits into one, and give that one commit a commit description that outlines the changes, and why they're being done.

sry, i messed up this PR when squashing the commits (be not using git for a while and it's bit different from the tool i used daily), so created a new one and replied there

@ylzh10 ylzh10 closed this Feb 19, 2025
@ylzh10 ylzh10 mentioned this pull request Feb 19, 2025
4 tasks
@ylzh10
Copy link
Author

ylzh10 commented Feb 19, 2025

created a new PR w/ one commit #95

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.

2 participants