Falcon::SmallMemBlockAlloc Class Reference

Small Memory Block Allocator. More...

#include <smba.h>

List of all members.

Classes

struct  tag_Page

Public Member Functions

void * alloc (unsigned int bytes)
 Allocates a small block wide at least bytes.
void free (void *bytes)
 Frees the given memory block.
 SmallMemBlockAlloc ()
 ~SmallMemBlockAlloc ()

Protected Types

enum  { page_list_size = 4 }
typedef struct
Falcon::SmallMemBlockAlloc::tag_Page 
PAGE_HEADER

Protected Member Functions

PAGE_HEADERnewPage (int blockSize)

Protected Attributes

Mutexm_mtx
void * page_free_lists [page_list_size]
 List of free pointers, organized for block size.
PAGE_HEADERpage_lists [page_list_size]
 Pages, organized for block size.


Detailed Description

Small Memory Block Allocator.

This is an optimized allocator which works with fixed size small memory blocks: 8, 16, 32 and 64 bytes respectively, without memory overhead for accounting.

The allocator manages directly heap pages and is able to determine the size of the allocated block by getting the address of the page from which it came from.

This allocator is useful to account very small data as the trie memory blocks, but can be cool also to store small strings, item references and all those things for which you may want a lightning fast memory allocator and zero memory overhead.

The engine provides a single SMBA for all the falcon.


Member Typedef Documentation


Member Enumeration Documentation

anonymous enum [protected]

Enumerator:
page_list_size 


Constructor & Destructor Documentation

Falcon::SmallMemBlockAlloc::SmallMemBlockAlloc (  ) 

Falcon::SmallMemBlockAlloc::~SmallMemBlockAlloc (  ) 


Member Function Documentation

void* Falcon::SmallMemBlockAlloc::alloc ( unsigned int  bytes  ) 

Allocates a small block wide at least bytes.

If the requested memory size is greater than the maximum size managed by this memory manager, function returns 0.

Parameters:
bytes Quantity of memory required.
Returns:
The allocated block.

void Falcon::SmallMemBlockAlloc::free ( void *  bytes  ) 

Frees the given memory block.

Parameters:
The memory block to be freed.

PAGE_HEADER* Falcon::SmallMemBlockAlloc::newPage ( int  blockSize  )  [protected]


Member Data Documentation

void* Falcon::SmallMemBlockAlloc::page_free_lists[page_list_size] [protected]

List of free pointers, organized for block size.

Pages, organized for block size.


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

Generated on Mon Oct 19 10:11:44 2009 for Falcon_Core by  doxygen 1.5.8