Skip to content

Commit

Permalink
fix: deallocate buffer with correct size
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoessbauer committed Jul 10, 2019
1 parent b047e92 commit 4453a94
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions drace-client/include/aligned-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,14 @@ namespace drace {
// copy this as value is modified by std::align
size_t space_size = _size_in_bytes;
_mem = dr_thread_alloc(drcontext, _size_in_bytes);
data = (T*)std::align(alignment, capacity, _mem, space_size);
// std::align changes pointer to memspace, hence copy
void * mem_align = _mem;
DR_ASSERT_MSG(
std::align(alignment, capacity, mem_align, space_size) != nullptr,
"could not allocate aligned memory");
data = (T*)mem_align;
DR_ASSERT(((uint64_t)data % alignment) == 0);
}
}
};
}
}

0 comments on commit 4453a94

Please sign in to comment.