Bitcoin Core  22.99.0
P2P Digital Currency
Public Member Functions | Private Attributes | List of all members
TestLockedPageAllocator Class Reference

Mock LockedPageAllocator for testing. More...

Inheritance diagram for TestLockedPageAllocator:
Collaboration diagram for TestLockedPageAllocator:

Public Member Functions

 TestLockedPageAllocator (int count_in, int lockedcount_in)
void * AllocateLocked (size_t len, bool *lockingSuccess) override
 Allocate and lock memory pages. More...
void FreeLocked (void *addr, size_t len) override
 Unlock and free memory pages. More...
size_t GetLimit () override
 Get the total limit on the amount of memory that may be locked by this process, in bytes. More...
- Public Member Functions inherited from LockedPageAllocator
virtual ~LockedPageAllocator ()

Private Attributes

int count
int lockedcount

Detailed Description

Mock LockedPageAllocator for testing.

Definition at line 134 of file allocator_tests.cpp.

Constructor & Destructor Documentation

◆ TestLockedPageAllocator()

TestLockedPageAllocator::TestLockedPageAllocator ( int  count_in,
int  lockedcount_in 

Definition at line 137 of file allocator_tests.cpp.

Member Function Documentation

◆ AllocateLocked()

void* TestLockedPageAllocator::AllocateLocked ( size_t  len,
bool *  lockingSuccess 

Allocate and lock memory pages.

If len is not a multiple of the system page size, it is rounded up. Returns nullptr in case of allocation failure.

If locking the memory pages could not be accomplished it will still return the memory, however the lockingSuccess flag will be false. lockingSuccess is undefined if the allocation fails.

Implements LockedPageAllocator.

Definition at line 138 of file allocator_tests.cpp.

◆ FreeLocked()

void TestLockedPageAllocator::FreeLocked ( void *  addr,
size_t  len 

Unlock and free memory pages.

Clear the memory before unlocking.

Implements LockedPageAllocator.

Definition at line 153 of file allocator_tests.cpp.

◆ GetLimit()

size_t TestLockedPageAllocator::GetLimit ( )

Get the total limit on the amount of memory that may be locked by this process, in bytes.

Return size_t max if there is no limit or the limit is unknown. Return 0 if no memory can be locked at all.

Implements LockedPageAllocator.

Definition at line 156 of file allocator_tests.cpp.

Member Data Documentation

◆ count

int TestLockedPageAllocator::count

Definition at line 161 of file allocator_tests.cpp.

◆ lockedcount

int TestLockedPageAllocator::lockedcount

Definition at line 162 of file allocator_tests.cpp.

The documentation for this class was generated from the following file: