MCPcopy Create free account
hub / github.com/dropbox/rust-alloc-no-stdlib / free_cell

Method free_cell

src/stack_allocator.rs:78–99  ·  view source on GitHub ↗
(self : &mut StackAllocator<'a, T, U>,
                 val : AllocatedStackMemory<'a, T>)

Source from the content-addressed store, hash-verified

76 }
77 }
78 fn free_cell(self : &mut StackAllocator<'a, T, U>,
79 val : AllocatedStackMemory<'a, T>) {
80 if val.slice().len() == 0 {
81 return;
82 }
83 if self.free_list_start > 0 {
84 self.free_list_start -=1;
85 let _ = core::mem::replace(&mut self.system_resources.slice_mut()[self.free_list_start],
86 val.mem);
87
88 } else {
89 for _i in 0..3 {
90 self.free_list_overflow_count += 1;
91 self.free_list_overflow_count %= self.system_resources.slice().len();
92 if self.system_resources.slice()[self.free_list_overflow_count].len() < val.mem.len() {
93 let _ = core::mem::replace(&mut self.system_resources.slice_mut()[self.free_list_overflow_count],
94 val.mem);
95 return;
96 }
97 }
98 }
99 }
100}

Callers

nothing calls this directly

Calls 3

lenMethod · 0.80
sliceMethod · 0.45
slice_mutMethod · 0.45

Tested by

no test coverage detected