fix: recursively size variable size structs in your buffer layouts (#27624)

This commit is contained in:
Steven Luscher 2022-09-06 22:37:27 -07:00 committed by GitHub
parent f420a89c2b
commit a94ada8b3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 0 deletions

View File

@ -152,6 +152,9 @@ export function getAlloc(type: any, fields: any): number {
if (Array.isArray(field)) {
return field.length * getItemAlloc(item.elementLayout);
}
} else if ('fields' in item) {
// This is a `Structure` whose size needs to be recursively measured.
return getAlloc({layout: item}, fields[item.property]);
}
// Couldn't determine allocated size of layout
return 0;