title: C++ Memory alignment in custom stack allocator
body: <p>Usually data is aligned at power of two addresses depending on its size.</p>
  
  <p>How should I align a struct or class with size of 20 bytes or another non-power-of-two size?</p>
  
  <p>I'm creating a custom stack allocator so I guess that the compiler wont align data for me since I'm working with a continuous block of memory.</p>
  
  <p><strong>Some more context:</strong></p>
  
  <p>I have an Allocator class that uses malloc() to allocate a large amount of data.
  Then I use void* allocate(U32 size_of_object) method to return the pointer that where I can store whether objects I need to store.
  This way all objects are stored in the same region of memory and it will hopefully fit in the cache reducing cache misses.</p>