Skip to content

Instantly share code, notes, and snippets.

@IUnknown68
Last active August 29, 2015 13:58
Show Gist options
  • Save IUnknown68/9933269 to your computer and use it in GitHub Desktop.
Save IUnknown68/9933269 to your computer and use it in GitHub Desktop.
BlockSizeInBytes - block size, alignment
// ---------------------------------------------------------------------------
// BlockSizeInBytes
// Returns the number of bytes required to hold <aCount> objects of type <T>
// in blocks of <aBlockSize> bytes.
template <typename T> inline size_t BlockSizeInBytes(size_t aCount, size_t aBlockSize = 4)
{
return (((aCount * sizeof(T)) + aBlockSize - 1) / aBlockSize) * aBlockSize;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment