8000 Return nullptr on 0 byte alloc by Thifhi · Pull Request #347 · LLNL/metall · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Return nullptr on 0 byte alloc #347

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

Merged
merged 1 commit into from
Mar 31, 2025
Merged

Return nullptr on 0 byte alloc #347

merged 1 commit into from
Mar 31, 2025

Conversation

Thifhi
Copy link
@Thifhi Thifhi commented Mar 28, 2025

Currently passing 0 to priv_allocate causes std::bad_alloc which is unexpected for an allocator and causes unnecessary problems with code like:

// Pseudo-code
void process(items):
    mem* = allocate(items.size())
    for (i in items):
        do_stuff(i, mem)
    dealloc(mem)

// Nothing to process
process([])

@KIwabuchi KIwabuchi self-requested a review March 30, 2025 22:57
@KIwabuchi KIwabuchi merged commit 5182d2c into LLNL:develop Mar 31, 2025
2 checks passed
@KIwabuchi
Copy link
Member

@Thifhi Thanks for the PR!

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
0