aboutsummaryrefslogtreecommitdiff
path: root/common/object/src/buffer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'common/object/src/buffer.rs')
-rw-r--r--common/object/src/buffer.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/common/object/src/buffer.rs b/common/object/src/buffer.rs
index dbde833..2f9d066 100644
--- a/common/object/src/buffer.rs
+++ b/common/object/src/buffer.rs
@@ -24,8 +24,9 @@ impl ObjectBuffer {
let mut temp = Vec::new();
for (tag, val) in fields {
tags.push(tag.0);
+ let off = (values.len() as u32) << 2;
if val.is_aligned() {
- offsets.push((values.len() as u32) << 2);
+ offsets.push(off);
val.store_aligned(&mut values);
} else {
temp.clear();
@@ -35,7 +36,7 @@ impl ObjectBuffer {
pad += 1;
temp.push(0);
}
- offsets.push(((values.len() as u32) << 2) | pad);
+ offsets.push(off | pad);
values.extend(bytemuck::cast_slice(&temp)); // ok bc. temp length is a whole number of dwords
}
}
@@ -60,3 +61,13 @@ impl From<Vec<u8>> for ObjectBuffer {
}))
}
}
+
+#[inline]
+pub(super) fn pad_vec(temp: &mut Vec<u8>) -> u32 {
+ let mut pad = 0;
+ while temp.len() % 4 != 0 {
+ pad += 1;
+ temp.push(0);
+ }
+ pad
+}