MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / align_to

Method align_to

crates/asm-to-binary/src/assembler/section.rs:77–86  ·  view source on GitHub ↗

Align the section to `alignment` bytes by zero-padding.

(&mut self, alignment: usize)

Source from the content-addressed store, hash-verified

75
76 /// Align the section to `alignment` bytes by zero-padding.
77 pub fn align_to(&mut self, alignment: usize) {
78 if alignment <= 1 {
79 return;
80 }
81 let rem = self.bytes.len() % alignment;
82 if rem != 0 {
83 let padding = alignment - rem;
84 self.bytes.extend(std::iter::repeat_n(0u8, padding));
85 }
86 }
87
88 pub fn define_label(&mut self, name: String) {
89 self.symbols.push((name, self.current_offset()));

Callers 1

encodeFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected