|
Atrinik Server 2.5
|
#include <global.h>Go to the source code of this file.
Functions | |
| uint32 | nearest_pow_two_exp (uint32 n) |
| void | setup_poolfunctions (struct mempool *pool, chunk_constructor constructor, chunk_destructor destructor) |
| struct mempool * | create_mempool (const char *description, uint32 expand, uint32 size, uint32 flags, chunk_initialisator initialisator, chunk_deinitialisator deinitialisator, chunk_constructor constructor, chunk_destructor destructor) |
| void | init_mempools () |
| static void | free_mempool (struct mempool *pool) |
| void | free_mempools () |
| static void | expand_mempool (struct mempool *pool, uint32 arraysize_exp) |
| void * | get_poolchunk_array_real (struct mempool *pool, uint32 arraysize_exp) |
| void | return_poolchunk_array_real (void *data, uint32 arraysize_exp, struct mempool *pool) |
| void | dump_mempool_statistics (object *op, int *sum_used, int *sum_alloc) |
Variables | |
| struct mempool_chunk | end_marker |
| int | nrof_mempools = 0 |
| struct mempool * | mempools [MAX_NROF_MEMPOOLS] |
| struct mempool * | pool_puddle |
| struct mempool * | pool_object |
| struct mempool * | pool_objectlink |
| struct mempool * | pool_player |
| struct mempool * | pool_bans |
| struct mempool * | pool_parties |
Basic pooling memory management system.
The mempool system never frees memory back to the system, but is extremely efficient when it comes to allocating and returning pool chunks.
Always use the get_poolchunk() and return_poolchunk() functions for getting and returning memory chunks. expand_mempool() is used internally.
Be careful if you want to use the internal chunk or pool data, its semantics and format might change in the future.
The Life Cycle of an Object:
attrsets are freed and given back to their respective pools too.
Definition in file mempool.c.
| void dump_mempool_statistics | ( | object * | op, |
| int * | sum_used, | ||
| int * | sum_alloc | ||
| ) |
Gather mempool statistics and write details to the log and the given player.
| op | To send detailed info to (optional). | |
| [out] | sum_used | Total number of bytes actively in use from mempools. |
| [out] | sum_alloc | Total number of bytes allocated by the mempool system. |
Expands the memory pool with MEMPOOL_EXPAND new chunks. All new chunks are put into the pool's freelist for future use. expand_mempool is only meant to be used from get_poolchunk().
| pool | Pool to expand. |
| arraysize_exp | The exponent for the array size, for example 3 for arrays of length 8 (2^3 = 8) |
| static void free_mempool | ( | struct mempool * | pool | ) | [static] |
| void free_mempools | ( | ) |
Free all the mempools previously initialized by init_mempools().
| void init_mempools | ( | ) |
| void setup_poolfunctions | ( | struct mempool * | pool, |
| chunk_constructor | constructor, | ||
| chunk_destructor | destructor | ||
| ) |
| struct mempool_chunk end_marker |
1.7.4