# OldMemoryPoolBase Struct Reference

Stuff for dynamic vehicles. More...

`#include <oldpool.h>`

Inherited by OldMemoryPool< T >.

## Public Member Functions
void | CleanPool ()
| Clean a pool in a safe way (does free all blocks).
bool | AddBlockToPool ()
| This function tries to increase the size of array by adding 1 block too it.
bool | AddBlockIfNeeded (uint index)
| Adds blocks to the pool if needed (and possible) till index fits inside the pool.
void | UpdateFirstFreeIndex (uint index)
| Check if the index of pool item being deleted is lower than cached first_free_index.
uint | GetSize () const
| Get the size of this pool, i.e.
bool | CanAllocateMoreBlocks () const
| Can this pool allocate more blocks, i.e.
uint | GetBlockCount () const
| Get the maximum number of allocable blocks.
const char * | GetName () const
| Get the name of this pool.
bool | CleaningPool () const
| Is the pool in the cleaning phase?
## Data Fields
const uint | item_size
| How many bytes one block is.
uint | first_free_index
| The index of the first free pool item in this pool.
byte ** | blocks
| An array of blocks (one block hold all the items).
## Protected Member Functions
| OldMemoryPoolBase (const char *name, uint max_blocks, uint block_size_bits, uint item_size, OldMemoryPoolNewBlock *new_block_proc, OldMemoryPoolCleanBlock *clean_block_proc)
## Protected Attributes
const char * | name
| Name of the pool (just for debugging).
const uint | max_blocks
| The max amount of blocks this pool can have.
const uint | block_size_bits
| The size of each block in bits.
OldMemoryPoolNewBlock * | new_block_proc
| Pointer to a function that is called after a new block is added.
OldMemoryPoolCleanBlock * | clean_block_proc
| Pointer to a function that is called to clean a block.
uint | current_blocks
| How many blocks we have in our pool.
uint | total_items
| How many items we now have in this pool.
bool | cleaning_pool
| Are we currently cleaning the pool?

## Detailed Description

Stuff for dynamic vehicles.

Use the wrappers to access the OldMemoryPool please try to avoid manual calls!

Definition at line 20 of file oldpool.h.

## Member Function Documentation

bool OldMemoryPoolBase::AddBlockToPool | ( |  | ) |

This function tries to increase the size of array by adding 1 block too it.

Returns:
  Returns false if the pool could not be increased

Definition at line 46 of file oldpool.cpp.

References block_size_bits, blocks, current_blocks, item_size, max_blocks, name, new_block_proc, ReallocT(), and total_items.

Referenced by AddBlockIfNeeded().

bool OldMemoryPoolBase::AddBlockIfNeeded | ( | uint | index | ) |

Adds blocks to the pool if needed (and possible) till index fits inside the pool.

Returns:
  Returns false if adding failed

Definition at line 78 of file oldpool.cpp.

References AddBlockToPool(), and total_items.

void OldMemoryPoolBase::UpdateFirstFreeIndex | ( | uint | index | ) | `[inline]`

Check if the index of pool item being deleted is lower than cached first_free_index.

Parameters:

  | index | index of pool item

Note:
  usage of min() will result in better code on some architectures

Definition at line 56 of file oldpool.h.

References first_free_index, and min().

uint OldMemoryPoolBase::GetSize | ( |  | ) | const`[inline]`

Get the size of this pool, i.e.

the total number of items you can put into it at the current moment; the pool might still be able to increase the size of the pool.

Returns:
  the size of the pool

Definition at line 67 of file oldpool.h.

References total_items.

bool OldMemoryPoolBase::CanAllocateMoreBlocks | ( |  | ) | const`[inline]`

Can this pool allocate more blocks, i.e.

is the maximum amount of allocated blocks not yet reached?

Returns:
  the if and only if the amount of allocable blocks is less than the amount of allocated blocks.

Definition at line 78 of file oldpool.h.

References current_blocks.

uint OldMemoryPoolBase::GetBlockCount | ( |  | ) | const`[inline]`

Get the maximum number of allocable blocks.

Returns:
  the numebr of blocks

Definition at line 87 of file oldpool.h.

References current_blocks.

const char* OldMemoryPoolBase::GetName | ( |  | ) | const`[inline]`

Get the name of this pool.

Returns:
  the name

Definition at line 96 of file oldpool.h.

bool OldMemoryPoolBase::CleaningPool | ( |  | ) | const`[inline]`

Is the pool in the cleaning phase?

Returns:
  true if it is

Definition at line 105 of file oldpool.h.

References cleaning_pool.

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

- src/oldpool.h
- src/oldpool.cpp