summaryrefslogtreecommitdiffstats
path: root/third_party/rust/object/src/write/util.rs
blob: 0ac65424af11c7a4882df3d1080766c965bad5b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use crate::alloc::vec::Vec;

pub(crate) fn align(offset: usize, size: usize) -> usize {
    (offset + (size - 1)) & !(size - 1)
}

pub(crate) fn align_u64(offset: u64, size: u64) -> u64 {
    (offset + (size - 1)) & !(size - 1)
}

pub(crate) fn write_align(buffer: &mut Vec<u8>, size: usize) {
    let offset = align(buffer.len(), size);
    buffer.resize(offset, 0);
}