gatb.core-API-1.4.2
MemoryCommon Class Reference

common implementation of IMemory interface More...

#include <MemoryCommon.hpp>

Inheritance diagram for MemoryCommon:
Inheritance graph

Public Member Functions

 MemoryCommon (IMemoryAllocator &alloc, IMemoryOperations &ope)
 
void * malloc (BlockSize_t size)
 
void * calloc (size_t nmemb, BlockSize_t size)
 
void * realloc (void *ptr, BlockSize_t size)
 
void free (void *ptr)
 
void * memset (void *s, int c, size_t n)
 
void * memcpy (void *dest, const void *src, size_t n)
 
int memcmp (const void *s1, const void *s2, size_t n)
 
size_t getNbBlocks ()
 
TotalSize_t getCurrentUsage ()
 
TotalSize_t getMaximumUsage ()
 
- Public Member Functions inherited from IMemory
virtual ~IMemory ()
 
- Public Member Functions inherited from IMemoryAllocator
virtual ~IMemoryAllocator ()
 
- Public Member Functions inherited from IMemoryOperations
virtual ~IMemoryOperations ()
 

Additional Inherited Members

- Public Types inherited from IMemoryAllocator
typedef u_int64_t BlockSize_t
 
typedef u_int64_t TotalSize_t
 

Detailed Description

common implementation of IMemory interface

This implementation delegates the allocation part to a referred IMemoryAllocator instance.

It is not abstract since it implements the statistics methods but with dummy return values. It could have sense in case we want fast allocators without statistic information.

Its main purpose is to factorize some code for concrete implementations.

Constructor & Destructor Documentation

MemoryCommon ( IMemoryAllocator alloc,
IMemoryOperations ope 
)
inline

Constructor.

Parameters
[in]alloc: the referred memory allocator.
[in]ope: the referred memory operations.

Member Function Documentation

void* calloc ( size_t  nmemb,
BlockSize_t  size 
)
inlinevirtual

See calloc documentation.

Implements IMemoryAllocator.

void free ( void *  ptr)
inlinevirtual

See free documentation.

Implements IMemoryAllocator.

TotalSize_t getCurrentUsage ( )
inlinevirtual

Get the memory usage by the current process.

Returns
the memory usage (in bytes).

Implements IMemory.

TotalSize_t getMaximumUsage ( )
inlinevirtual

Get the maximum reached size.

Returns
the maximum used memory (in bytes).

Implements IMemory.

size_t getNbBlocks ( )
inlinevirtual

Get the number of currently allocated memory blocks.

Returns
the number of allocated blocks.

Implements IMemory.

void* malloc ( BlockSize_t  size)
inlinevirtual

See malloc documentation.

Implements IMemoryAllocator.

int memcmp ( const void *  s1,
const void *  s2,
size_t  n 
)
inlinevirtual

Same as memcpy from <string.h>

Implements IMemoryOperations.

void* memcpy ( void *  dest,
const void *  src,
size_t  n 
)
inlinevirtual

Same as memcpy from <string.h>

Implements IMemoryOperations.

void* memset ( void *  s,
int  c,
size_t  n 
)
inlinevirtual

Same as memset from <string.h>

Implements IMemoryOperations.

void* realloc ( void *  ptr,
BlockSize_t  size 
)
inlinevirtual

See realloc documentation.

Implements IMemoryAllocator.


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