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 a option to allow null "main" #76

Closed
xtexChooser opened this issue Aug 20, 2023 · 3 comments
Closed

Add a option to allow null "main" #76

xtexChooser opened this issue Aug 20, 2023 · 3 comments
Assignees

Comments

@xtexChooser
Copy link
Contributor

xtexChooser commented Aug 20, 2023

if (main == NULL) {

if (! main) {

For example, I am writing an OS and manage the whole linear memory with this allocator.
However, this check is also useful to general usages.

Thanks. This is a pretty-good library.

@spaskalev spaskalev self-assigned this Aug 20, 2023
@spaskalev
Copy link
Owner

Thanks for the feedback! These checks are added to assist users but for managing memory that starts at 0 I can see how this can be an issue.

@xtexChooser
Copy link
Contributor Author

ops sorry I found that managing the first page is impossible because 0 will be regarded as allocation failure. Sorry

@spaskalev
Copy link
Owner

ops sorry I found that managing the first page is impossible because 0 will be regarded as allocation failure. Sorry

Thinking about it, there's no reason not to be able to do this. The allocation logic itself is handled by the tree component and the allocator just maps tree positions to addresses and vice-versa. It is doable to redo the allocator component with a different API (e.g. struct alloc_result { void * addr; size_t result }) and still use the zero page.

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

No branches or pull requests

2 participants