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

provide an error code out argument for o1heapInit #17

Open
thirtytwobits opened this issue Apr 21, 2023 · 6 comments
Open

provide an error code out argument for o1heapInit #17

thirtytwobits opened this issue Apr 21, 2023 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@thirtytwobits
Copy link

int error_code = O1HEAP_NO_ERROR;
O1HeapInstance* h = o1heapInit(my_buffer, my_buffer_size, &error_code);

if (error_code == O1HEAP_ERR_BASE_TOO_SMALL)
{
    throw my_buffer_too_small_exception();
}

etc.

@pavel-kirienko
Copy link
Owner

There are no other error cases so having an error code will add no new information to the user.

@pavel-kirienko
Copy link
Owner

I take that back. There are two error cases: bad alignment and the arena being too small. Does this justify the existence of a separate argument?

@thirtytwobits
Copy link
Author

I'm struggling to figure out what I'm doing wrong right now so...yes?

@pavel-kirienko
Copy link
Owner

Can I name the error code argument after you?

@pavel-kirienko pavel-kirienko self-assigned this Apr 21, 2023
@pavel-kirienko pavel-kirienko added the enhancement New feature or request label Apr 21, 2023
@thirtytwobits
Copy link
Author

yes

@thirtytwobits
Copy link
Author

perhaps if you provided a way to query the required minimum size then you can document that the failure is either that or that the pointer was not aligned per O1HEAP_ALIGNMENT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants