You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if new_size == 0{Err(error::BannedZeroSizedAllocationsError)? }// see ZST_SUPPORTED rant above
109
120
// SAFETY: ✔️ `ptr` belongs to `self` per thin::Realloc's documented safety preconditions - and thus was allocated with `Global{,Re}Alloc` - which should be safe to `GlobalReAlloc`.
110
121
let alloc = unsafe{GlobalReAlloc(ptr.as_ptr().cast(), new_size,0)};
if new_size == 0{Err(error::BannedZeroSizedAllocationsError)? }// see ZST_SUPPORTED rant above
115
127
// SAFETY: ✔️ `GMEM_ZEROINIT` should ensure the newly reallocated memory is zeroed.
116
128
// SAFETY: ✔️ `ptr` belongs to `self` per thin::Realloc's documented safety preconditions - and thus was allocated with `Global{,Re}Alloc` - which should be safe to `GlobalReAlloc`.
117
129
let alloc = unsafe{GlobalReAlloc(ptr.as_ptr().cast(), new_size,GMEM_ZEROINIT)};
@@ -178,13 +190,17 @@ unsafe impl thin::SizeOfDebug for Global {
if new_size == 0{Err(error::BannedZeroSizedAllocationsError)? }// see ZST_SUPPORTED rant
109
120
// SAFETY: ✔️ `ptr` belongs to `self` per thin::Realloc's documented safety preconditions - and thus was allocated with `Local{,Re}Alloc` - which should be safe to `LocalReAlloc`.
110
121
let alloc = unsafe{LocalReAlloc(ptr.as_ptr().cast(), new_size,0)};
if new_size == 0{Err(error::BannedZeroSizedAllocationsError)? }// see ZST_SUPPORTED rant
115
127
// SAFETY: ✔️ `LMEM_ZEROINIT` should ensure the newly reallocated memory is zeroed.
116
128
// SAFETY: ✔️ `ptr` belongs to `self` per thin::Realloc's documented safety preconditions - and thus was allocated with `Local{,Re}Alloc` - which should be safe to `LocalReAlloc`.
117
129
let alloc = unsafe{LocalReAlloc(ptr.as_ptr().cast(), new_size,LMEM_ZEROINIT)};
@@ -180,11 +192,15 @@ unsafe impl thin::SizeOfDebug for Local {
@@ -18,11 +25,15 @@ use core::fmt::{self, Debug, Display, Formatter};
18
25
pubrequested:usize,
19
26
}
20
27
28
+
implDisplayforBannedZeroSizedAllocationsError{fnfmt(&self,f:&mutFormatter<'_>) -> fmt::Result{write!(f,"requested a 0-sized allocation, but those have inconsistent behavior with this allocator")}}
21
29
implDisplayforExcessiveAlignmentRequestedError{fnfmt(&self,f:&mutFormatter<'_>) -> fmt::Result{write!(f,"requested {:?} alignment, but a maximum of {:?} is supported",self.requested,self.supported)}}
22
30
implDisplayforExcessiveSliceRequestedError{fnfmt(&self,f:&mutFormatter<'_>) -> fmt::Result{write!(f,"requested {} elements, but that would result in a LayoutError",self.requested)}}
#[cfg(feature = "std")]impl std::error::ErrorforBannedZeroSizedAllocationsError{fndescription(&self) -> &str{"requested a 0-sized allocation, but those have inconsistent behavior with this allocator"}}
25
35
#[cfg(feature = "std")]impl std::error::ErrorforExcessiveAlignmentRequestedError{fndescription(&self) -> &str{"requested more alignment than was supported"}}
26
36
#[cfg(feature = "std")]impl std::error::ErrorforExcessiveSliceRequestedError{fndescription(&self) -> &str{"requested too many elements"}}
0 commit comments