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

Question: how to get 16 byte aligned address using ZoneHeap? #38

Open
mouhgh96 opened this issue May 30, 2021 · 0 comments
Open

Question: how to get 16 byte aligned address using ZoneHeap? #38

mouhgh96 opened this issue May 30, 2021 · 0 comments

Comments

@mouhgh96
Copy link

mouhgh96 commented May 30, 2021

Hi,
i'm try to build a simple memory allocator(as an assignment poject) and i found Heap layers very interesting
using Allocator = FreelistHeap<ZoneHeap<SizedMmapHeap, 1024 * 8>>;
when defining my allocator as shown above i don't get 16 byte aligned address
after reading the source code i have found :

class Arena {
  public:
    Arena() {
      static_assert((sizeof(Arena) % MallocInfo::Alignment == 0),
              "Alignment must match Arena size.");
    }

    Arena * nextArena;
    char * arenaSpace;
    size_t arenaSize;
  };

as Arena is never instantiated explicitly the static_assert fail silently i don't know if it's intentional, in my case i added a dummy
pointer to solve the problem (is there a better solution or am i using heap layer the wrong way)
thanks

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

1 participant