| libdatatypes 0.3.2
    Abstract datatypes for C. | 
Allocate memory blocks of same sizes. More...
#include <stdint.h>#include <stddef.h>Go to the source code of this file.
| Data Structures | |
| struct | Pool | 
| Allocate groups of equal-sized chunks of memory.  More... | |
| struct | MemoryPool | 
| This memory pool allocates blocks of memory and grows automatically.  More... | |
| struct | MemoryPool::_MemoryBlock | 
| Blocks of memory are stored in a singly-linked list.  More... | |
| struct | MemoryPool::_MemoryPtrBlock | 
| Freed pointers are stored in blocks holding addresses.  More... | |
| Functions | |
| MemoryPool * | memory_pool_new (size_t item_size, size_t block_size) | 
| void | memory_pool_destroy (MemoryPool *pool) | 
Allocate memory blocks of same sizes.
Definition in file pool.h.
| struct MemoryPool | 
This memory pool allocates blocks of memory and grows automatically.
| Data Fields | ||
|---|---|---|
| struct _MemoryBlock * | block | First memory block. | 
| size_t | block_size | Number of items a memory memory can hold. | 
| struct _MemoryPtrBlock * | free_block | First pointer block. | 
| size_t | item_size | Size of an allocated item. | 
| Pool | padding | Padding. | 
| struct MemoryPool::_MemoryBlock | 
| Data Fields | ||
|---|---|---|
| int8_t * | items | The allocated memory block. | 
| struct _MemoryBlock * | next | Pointer to next available memory block or NULL. | 
| size_t | offset | Offset of the next available address. | 
| struct MemoryPool::_MemoryPtrBlock | 
| Data Fields | ||
|---|---|---|
| void ** | items | Array containing freed pointers. | 
| struct _MemoryPtrBlock * | next | Pointer to next memory or NULL. | 
| size_t | offset | Offset to find next available position in items array. | 
| void memory_pool_destroy | ( | MemoryPool * | pool | ) | 
| pool | MemoryPool to destroy | 
Destroys the given MemoryPool.
| MemoryPool * memory_pool_new | ( | size_t | item_size, | 
| size_t | block_size | ||
| ) | 
| item_size | size of allocated items | 
| block_size | number of elements a memory can hold | 
Creates a new MemoryPool.