#![allow(clippy::module_name_repetitions)]
use std::alloc::LayoutError;
use thiserror::Error;
#[derive(Debug, Error, PartialEq, Eq, Clone)]
pub enum AllocationError {
#[error("An arithmetic error occurred.")]
ArithmeticError,
#[error(transparent)]
LayoutError(#[from] LayoutError),
#[error("Process ran out of memory.")]
OutOfMemory,
}
#[derive(Debug, Error, PartialEq, Eq, Clone)]
pub enum DeallocationError {
#[error("This allocation's marker is corrupted, either memory corruption occurred, or a pointer not allocated by this crate's alloc was passed to realloc or free.")]
CorruptedMarker,
#[error("This memory was already freed.")]
DoubleFree,
#[error("The pointer provided was not properly aligned.")]
ImproperAlignment,
#[error(transparent)]
LayoutError(#[from] LayoutError),
#[error("Tried to free a null pointer.")]
NullPtr,
}
#[derive(Debug, Error, PartialEq, Eq, Clone)]
pub enum ReallocationError {
#[error(transparent)]
AllocationError(#[from] AllocationError),
#[error(transparent)]
DeallocationError(#[from] DeallocationError),
#[error("The pointer provided was not properly aligned.")]
ImproperAlignment,
#[error("The pointer provided points to already freed memory.")]
MarkerFree,
#[error("The pointer provided has a corrupted marker, was it allocated by this crate?")]
MarkerCorrupted,
#[error("The new allocation failed, but your old pointer remains valid.")]
NewAllocationFailed(*mut u8),
}