Fix not considering alignment of 8 bit when calculating size for indexedarray and enumedarray

This commit is contained in:
Jan 2022-03-22 16:08:55 +01:00
parent 8133f4d57e
commit f236d285b6

View File

@ -3,6 +3,7 @@
#include <cassert>
#include "CommonStructuredDataDef.h"
#include "Utils/Alignment.h"
CommonStructuredDataType::CommonStructuredDataType()
: m_category(CommonStructuredDataTypeCategory::UNKNOWN),
@ -58,7 +59,7 @@ size_t CommonStructuredDataType::GetSizeInBits(const CommonStructuredDataDef& de
return 0u;
}
const auto& indexedArray = def.m_indexed_arrays[m_info.type_index];
return indexedArray.m_element_size_in_bits * indexedArray.m_element_count;
return utils::Align(indexedArray.m_element_size_in_bits * indexedArray.m_element_count, 8u);
}
case CommonStructuredDataTypeCategory::ENUM_ARRAY:
{
@ -68,7 +69,7 @@ size_t CommonStructuredDataType::GetSizeInBits(const CommonStructuredDataDef& de
return 0u;
}
const auto& enumedArray = def.m_enumed_arrays[m_info.type_index];
return enumedArray.m_element_size_in_bits * enumedArray.m_element_count;
return utils::Align(enumedArray.m_element_size_in_bits * enumedArray.m_element_count, 8u);
}
case CommonStructuredDataTypeCategory::UNKNOWN: