[][src]Crate owned_alloc

Owned Allocations. A crate to help reducing manual memory management errors.

The idea is to use a type like UninitAlloc for uninitialized dynamic allocations. After initializing it, you have a OwnedAlloc which is pretty similar to a Box. However, unlike a Box, you may move the value out from the OwnedAlloc and getting an UninitAlloc back.

For vec-like structures, a type RawVec is available, pretty similar to the one used by the standard library. Currently, no other help is provided for arrays/vectors.

There is also a type Cache, which is actually more general than allocation, but may be useful for allocations. It can save unused allocations requested on a tight loop.

Structs

AllocErr

Error returned from the allocator.

Cache

A general purpouse cache suitable for saving discarted memory allocations in a tight loop.

LayoutErr

Error caused by invalid size or alignment.

OwnedAlloc

Dynamic allocation of a T whose memory is considered fully initialized. The allocation and its content are freed on drop. Similar to a Box. If the size of the allocation is zero, no allocation is performed and a dangling pointer is used (just like in std). For the drop checker, the type acts as if it contains a T due to usage of PhantomData<T>.

RawVec

Raw Vector allocation. This allocation, instead of holding a pointer to a single T, holds a pointer to as many T are required. The allocation is resizable and is freed on drop. No initialization or deinitialization of the elements is performed. This type may be useful for Vec-like types. If the size of the allocation is zero, no allocation is performed and a dangling pointer is used (just like in std). For the drop checker, the type acts as if it contains a T due to usage of PhantomData<T>.

UninitAlloc

Dynamic allocation of a T whose memory is considered uninitialized. The allocation is freed on drop. If the size of the allocation is zero, no allocation is performed and a dangling pointer is used (just like in std). For the drop checker, the type acts as if it contains a T due to usage of PhantomData<T>.

Enums

MaybeUninitAlloc

Pointer to memory allocaation that might be either initialized or uninitialized. For the drop checker, the type acts as if it contains a T due to usage of PhantomData<T>.

RawVecErr

Errors returned by the RawVec.