Struct bitcoin_support::LockedPool
source · pub struct LockedPool { /* private fields */ }Expand description
| Pool for locked memory chunks. | | To avoid sensitive key data from being | swapped to disk, the memory in this pool | is locked/pinned. | | An arena manages a contiguous region | of memory. The pool starts out with one | arena but can grow to multiple arenas | if the need arises. | | Unlike a normal C heap, the administrative | structures are separate from the managed | memory. This has been done as the sizes | and bases of objects are not in themselves | sensitive information, as to conserve | precious locked memory. In some operating | systems the amount of memory that can | be locked is small. |
Implementations§
source§impl LockedPool
impl LockedPool
sourcepub fn new(
_allocator_in: Box<dyn LockedPageAllocator>,
_lf_cb_in: LockingFailed_Callback
) -> Self
pub fn new( _allocator_in: Box<dyn LockedPageAllocator>, _lf_cb_in: LockingFailed_Callback ) -> Self
| Create a new LockedPool. This takes | ownership of the MemoryPageLocker, | you can only instantiate this with LockedPool(std::move(…)). | | The second argument is an optional callback | when locking a newly allocated arena | failed. | | If this callback is provided and returns | false, the allocation fails (hard fail), | if it returns true the allocation proceeds, | but it could warn. |
sourcepub fn alloc(&mut self, _size: usize)
pub fn alloc(&mut self, _size: usize)
| Allocate size bytes from this arena. | | Returns pointer on success, or 0 if memory | is full or the application tried to allocate | 0 bytes. |
sourcepub fn free(&mut self, _ptr: *mut c_void)
pub fn free(&mut self, _ptr: *mut c_void)
| Free a previously allocated chunk of | memory. | | Freeing the zero pointer has no effect. | | Raises std::runtime_error in case | of error. |