-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathpool.h
More file actions
32 lines (26 loc) · 638 Bytes
/
pool.h
File metadata and controls
32 lines (26 loc) · 638 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include <stdint.h>
#define POOL_BLOCKS_INITIAL 1
typedef struct poolFreed{
struct poolFreed *nextFree;
} poolFreed;
typedef struct {
uint32_t elementSize;
uint32_t blockSize;
uint32_t used;
int32_t block;
poolFreed *freed;
uint32_t blocksUsed;
uint8_t **blocks;
} pool;
void poolInitialize(pool *p, const uint32_t elementSize, const uint32_t blockSize);
void poolFreePool(pool *p);
#ifndef DISABLE_MEMORY_POOLING
void *poolMalloc(pool *p);
void poolFree(pool *p, void *ptr);
#else
#include <stdlib.h>
#define poolMalloc(p) malloc((p)->blockSize)
#define poolFree(p, d) free(d)
#endif
void poolFreeAll(pool *p);