SmallestTypeWhichHasAtLeastNBitsStruct<ALIGNMENT_SUB_BINS_AMOUNT>: SmallestTypeWhichHasAtLeastNBitsTrait
Expand description

A spin locked memory allocator that can be used as the global allocator.


Creates an empty locked heap allocator without any heap memory region, which will always return null on allocation requests.

To intiialize this allocator, use the init method.

Initializes the heap allocator with the given memory region.


If the allocator was already initialized, this function will panic.

The SpinLockedAllocator on which this was called must not be moved, and its address in memory must not change, otherwise undefined behaviour will occur. This is because the heap region now contains pointers to fields of this struct, and if this struct will move, the address of its fields will change, and those pointers will now be invalid.

The provided memory region must be valid and non-null, and must not be used by anything else.

If after aligning the start and end addresses, the size of the heap is 0, the function panics.

Checks if the heap memory region was already initialized by calling init.

Trait Implementations

Allocate memory as described by the given layout. Read more
Deallocate the block of memory at the given ptr pointer with the given layout. Read more
Shrink or grow a block of memory to the given new_size. The block is described by the given ptr pointer and layout. Read more
Behaves like alloc, but also ensures that the contents are set to zero before being returned. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.