9 namespace groupallocator {
14 inline size_t getPadding(
size_t startingptr,
size_t alignment) {
15 size_t multiplier = startingptr / alignment + 1;
16 size_t padding = multiplier * alignment - startingptr;
33 l.push_back({s, 0, p});
40 inline void alloc(T **p,
size_t s,
bool forceAligned128) {
41 size_t alignment = forceAligned128 ? 128 : std::alignment_of<T *>();
43 for(
auto iter = l.begin(); iter != l.end(); ++iter) {
45 if(iter->used == 0 &&
getPadding((
size_t)iter->start, alignment) + s <= iter->size){
47 *p = (T*) iter->start;
49 size_t prevSize = iter->size;
50 void* prevStart = iter->start;
52 iter->size = s +
getPadding((
size_t)iter->start, alignment);
55 MallocData m = {prevSize - iter->size, 0, (
void*)((
size_t)prevStart + iter->size)};
69 if((
size_t)iter.start == (
size_t)p){
79 std::list<MallocData> l;