Kea 2.7.6
isc::util::MemorySegmentLocal Class Reference

malloc/free based Memory Segment class More...

#include <memory_segment_local.h>

+ Inheritance diagram for isc::util::MemorySegmentLocal:

Public Member Functions

 MemorySegmentLocal ()
 Constructor.
 
virtual ~MemorySegmentLocal ()
 Destructor.
 
virtual bool allMemoryDeallocated () const
 Check if all allocated memory was deallocated.
 
virtual void * allocate (size_t size)
 Allocate/acquire a segment of memory.
 
virtual bool clearNamedAddressImpl (const char *name)
 Local segment version of clearNamedAddress.
 
virtual void deallocate (void *ptr, size_t size)
 Free/release a segment of memory.
 
virtual NamedAddressResult getNamedAddressImpl (const char *name) const
 Local segment version of getNamedAddress.
 
virtual bool setNamedAddressImpl (const char *name, void *addr)
 Local segment version of setNamedAddress.
 
- Public Member Functions inherited from isc::util::MemorySegment
virtual ~MemorySegment ()
 Destructor.
 
bool clearNamedAddress (const char *name)
 Delete a name previously associated with a segment address.
 
NamedAddressResult getNamedAddress (const char *name) const
 Return the address in the segment that has the given name.
 
bool setNamedAddress (const char *name, void *addr)
 Associate specified address in the segment with a given name.
 

Additional Inherited Members

- Public Types inherited from isc::util::MemorySegment
typedef std::pair< bool, void * > NamedAddressResult
 Type definition for result returned by getNamedAddress()
 
- Protected Member Functions inherited from isc::util::MemorySegment

Detailed Description

malloc/free based Memory Segment class

This class specifies a concrete implementation for a malloc/free based MemorySegment. Please see the MemorySegment class documentation for usage.

Definition at line 23 of file memory_segment_local.h.

Constructor & Destructor Documentation

◆ MemorySegmentLocal()

isc::util::MemorySegmentLocal::MemorySegmentLocal ( )
inline

Constructor.

Creates a local memory segment object

Definition at line 28 of file memory_segment_local.h.

◆ ~MemorySegmentLocal()

virtual isc::util::MemorySegmentLocal::~MemorySegmentLocal ( )
inlinevirtual

Destructor.

Definition at line 32 of file memory_segment_local.h.

Member Function Documentation

◆ allMemoryDeallocated()

bool isc::util::MemorySegmentLocal::allMemoryDeallocated ( ) const
virtual

Check if all allocated memory was deallocated.

Returns
Returns true if all allocated memory was deallocated, false otherwise.

Implements isc::util::MemorySegment.

Definition at line 44 of file memory_segment_local.cc.

◆ allocate()

void * isc::util::MemorySegmentLocal::allocate ( size_t size)
virtual

Allocate/acquire a segment of memory.

The source of the memory is libc's malloc().

Throws std::bad_alloc if the implementation cannot allocate the requested storage.

Parameters
sizeThe size of the memory requested in bytes.
Returns
Returns pointer to the memory allocated.

Implements isc::util::MemorySegment.

Definition at line 16 of file memory_segment_local.cc.

◆ clearNamedAddressImpl()

bool isc::util::MemorySegmentLocal::clearNamedAddressImpl ( const char * name)
virtual

Local segment version of clearNamedAddress.

There's a small chance this method could throw std::bad_alloc. It should be considered a fatal error.

Implements isc::util::MemorySegment.

Definition at line 65 of file memory_segment_local.cc.

◆ deallocate()

void isc::util::MemorySegmentLocal::deallocate ( void * ptr,
size_t size )
virtual

Free/release a segment of memory.

This method may throw isc::OutOfRange if size is not equal to the originally allocated size.

Parameters
ptrPointer to the block of memory to free/release. This should be equal to a value returned by allocate().
sizeThe size of the memory to be freed in bytes. This should be equal to the number of bytes originally allocated.

Implements isc::util::MemorySegment.

Definition at line 27 of file memory_segment_local.cc.

References isc_throw.

◆ getNamedAddressImpl()

MemorySegment::NamedAddressResult isc::util::MemorySegmentLocal::getNamedAddressImpl ( const char * name) const
virtual

Local segment version of getNamedAddress.

There's a small chance this method could throw std::bad_alloc. It should be considered a fatal error.

Implements isc::util::MemorySegment.

Definition at line 49 of file memory_segment_local.cc.

◆ setNamedAddressImpl()

bool isc::util::MemorySegmentLocal::setNamedAddressImpl ( const char * name,
void * addr )
virtual

Local segment version of setNamedAddress.

This version does not validate the given address to see whether it belongs to this segment.

This implementation of this method always returns false (but the application should expect a return value of true unless it knows the memory segment class is MemorySegmentLocal and needs to exploit the fact).

Implements isc::util::MemorySegment.

Definition at line 59 of file memory_segment_local.cc.


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