pool: avoid alignment warnings on ARM

This commit is contained in:
Danny Robson 2017-01-05 19:50:00 +11:00
parent 98dc992473
commit ee53f8234b
2 changed files with 25 additions and 25 deletions

View File

@ -28,39 +28,39 @@ namespace util {
/// item destructors at pool destruction time.
template <typename T>
class pool : public nocopy {
protected:
union node {
node *_node;
char _data[sizeof (T)];
};
protected:
union alignas (T) node {
node *_node;
char _data[sizeof (T)];
};
node *m_head; // root address of allocation
node *m_next; // next available entry in the linked list
node *m_head; // root address of allocation
node *m_next; // next available entry in the linked list
const size_t m_capacity;
size_t m_size;
const size_t m_capacity;
size_t m_size;
public:
explicit
pool (unsigned int _capacity);
public:
explicit
pool (unsigned int _capacity);
~pool ();
~pool ();
// Data management
template <typename ...Args>
T* acquire (Args&... args);
// Data management
template <typename ...Args>
T* acquire (Args&... args);
void release (T *data);
void release (T *data);
size_t capacity (void) const;
size_t size (void) const;
bool empty (void) const;
size_t capacity (void) const;
size_t size (void) const;
bool empty (void) const;
// Indexing
size_t index (const T*) const;
// Indexing
size_t index (const T*) const;
T& operator[] (size_t idx) &;
const T& operator[] (size_t idx) const&;
T& operator[] (size_t idx) &;
const T& operator[] (size_t idx) const&;
};
}

View File

@ -98,7 +98,7 @@ namespace util {
// save what will become the next node shortly. it could be overwritten
// in the constructor we're about to call.
node *newnext = m_next->_node;
T *data = reinterpret_cast<T*> (m_next->_data);
T *data = reinterpret_cast<T*> (m_next);
// try to construct the returnable object.
try {