You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Is it possible to implement O(1) memalign?
The text was updated successfully, but these errors were encountered: