add btAlignPointer template and use it in serializer/allocator
this should fix Issue 559
This commit is contained in:
@@ -519,4 +519,21 @@ struct btTypedObject
|
||||
return m_objectType;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
///align a pointer to the provided alignment, upwards
|
||||
template <typename T>T* btAlignPointer(T* unalignedPtr, size_t alignment)
|
||||
{
|
||||
union
|
||||
{
|
||||
T* ptr;
|
||||
size_t integer;
|
||||
};
|
||||
const size_t bit_mask = ~(alignment - 1);
|
||||
ptr = unalignedPtr;
|
||||
integer += alignment-1;
|
||||
integer &= bit_mask;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#endif //BT_SCALAR_H
|
||||
|
||||
Reference in New Issue
Block a user