MCPcopy Create free account
hub / github.com/aiscriptdev/aiscript / shrink

Method shrink

aiscript-arena/src/allocator_api.rs:116–128  ·  view source on GitHub ↗
(
        &self,
        ptr: NonNull<u8>,
        old_layout: Layout,
        new_layout: Layout,
    )

Source from the content-addressed store, hash-verified

114
115 #[inline]
116 unsafe fn shrink(
117 &self,
118 ptr: NonNull<u8>,
119 old_layout: Layout,
120 new_layout: Layout,
121 ) -> Result<NonNull<[u8]>, AllocError> {
122 unsafe {
123 let ptr = self.allocator.shrink(ptr, old_layout, new_layout)?;
124 self.metrics
125 .mark_external_deallocation(old_layout.size() - new_layout.size());
126 Ok(ptr)
127 }
128 }
129}
130
131unsafe impl<A: 'static> Collect for MetricsAlloc<'_, A> {

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected