minor, reuse StructAtOffset logic in StructAtOffsetOrNull

This commit is contained in:
Ebrahim Byagowi 2019-06-28 23:44:14 +04:30 committed by GitHub
parent 9db7ce73d7
commit ddd29e5594
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -41,13 +41,13 @@ using namespace OT;
/* utility macro */
template<typename Type>
static inline const Type& StructAtOffsetOrNull (const void *P, unsigned int offset)
{ return offset? (* reinterpret_cast<const Type*> ((const char *) P + offset)): Null(Type); }
{ return offset ? StructAtOffset<Type> (P, offset) : Null (Type); }
inline unsigned int calcOffSize (unsigned int dataSize)
{
unsigned int size = 1;
unsigned int offset = dataSize + 1;
while ((offset & ~0xFF) != 0)
while (offset & ~0xFF)
{
size++;
offset >>= 8;