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

Feature request: memalign allocation. #13

Open
tuanhtrng opened this issue Aug 8, 2022 · 2 comments
Open

Feature request: memalign allocation. #13

tuanhtrng opened this issue Aug 8, 2022 · 2 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@tuanhtrng
Copy link

Is it possible to implement O(1) memalign?

@pavel-kirienko
Copy link
Owner

I see two solutions immediately (there may be other, less apparent solutions):

  • Non-intrusive solution that you can implement in your application: Given a requirement of $M$ bytes aligned at $A$, invoke $\texttt{o1heapAllocate}\left(\text{instance}, M+A\right)$, then bump the returned pointer to $A$. Do not lose the original pointer as you will need it to deallocate the memory (hint: you may store the original pointer in the allocated fragment).

  • Intrusive solution that requires changes to the library: redefine O1HEAP_ALIGNMENT. This will affect memory consumption/fragmentation for all allocations, though.

@pavel-kirienko pavel-kirienko added enhancement New feature or request question Further information is requested labels Aug 8, 2022
@thirtytwobits
Copy link

I'd like to see a solution where o1heapAllocateOveraligned(O1HeapInstance* const handle, const size_t amount, const size_t alignment) is added to o1heap such that the user doesn't have to implement a pointer mapping scheme outside of o1heap.

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

No branches or pull requests

3 participants