libdatatypes 0.3.2
Abstract datatypes for C.
Loading...
Searching...
No Matches
pool.h
Go to the documentation of this file.
1/***************************************************************************
2 begin........: June 2012
3 copyright....: Sebastian Fedrau
4 email........: sebastian.fedrau@gmail.com
5 ***************************************************************************/
6
7/***************************************************************************
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License v3 as published by
10 the Free Software Foundation.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License v3 for more details.
16 ***************************************************************************/
22#ifndef POOL_H
23#define POOL_H
24
25#include <stdint.h>
26#include <stddef.h>
27
32typedef struct _Pool
33{
35 void *(*alloc)(struct _Pool *pool);
37 void (*free)(struct _Pool *pool, void *ptr);
38} Pool;
39
44typedef struct
45{
48
57 {
59 int8_t *items;
61 size_t offset;
64 } *block;
73 {
75 void **items;
77 size_t offset;
80 } *free_block;
82 size_t block_size;
84 size_t item_size;
86
94MemoryPool *memory_pool_new(size_t item_size, size_t block_size);
95
102
103#endif
104
Pool padding
Definition pool.h:47
struct _MemoryBlock * next
Definition pool.h:63
void memory_pool_destroy(MemoryPool *pool)
Definition pool.c:202
MemoryPool * memory_pool_new(size_t item_size, size_t block_size)
Definition pool.c:175
size_t item_size
Definition pool.h:84
struct _MemoryPtrBlock * next
Definition pool.h:79
size_t block_size
Definition pool.h:82
This memory pool allocates blocks of memory and grows automatically.
Definition pool.h:45
Blocks of memory are stored in a singly-linked list.
Definition pool.h:57
Freed pointers are stored in blocks holding addresses.
Definition pool.h:73
Allocate groups of equal-sized chunks of memory.
Definition pool.h:33