/[LeafOK_CVS]/lbbs/include/memory_pool.h
ViewVC logotype

Contents of /lbbs/include/memory_pool.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Sat Jan 3 10:27:14 2026 UTC (2 months, 1 week ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +1 -1 lines
Content type: text/x-chdr
Update copyright info

1 /* SPDX-License-Identifier: GPL-3.0-or-later */
2 /*
3 * memory_pool
4 * - memory pool
5 *
6 * Copyright (C) 2004-2026 Leaflet <leaflet@leafok.com>
7 */
8
9 #ifndef _MEMORY_POOL_H_
10 #define _MEMORY_POOL_H_
11
12 #include <stddef.h>
13
14 struct memory_pool_t
15 {
16 size_t node_size;
17 size_t node_count_per_chunk;
18 int chunk_count;
19 int chunk_count_limit;
20 void **p_chunks;
21 void *p_free;
22 int node_count_allocated;
23 int node_count_free;
24 int node_count_total;
25 };
26 typedef struct memory_pool_t MEMORY_POOL;
27
28 extern MEMORY_POOL *memory_pool_init(size_t node_size, size_t node_count_per_chunk, int chunk_count_limit);
29 extern void memory_pool_cleanup(MEMORY_POOL *p_pool);
30
31 extern void *memory_pool_alloc(MEMORY_POOL *p_pool);
32 extern void memory_pool_free(MEMORY_POOL *p_pool, void *p_node);
33
34 // For debug only
35 extern int memory_pool_check_node(MEMORY_POOL *p_pool, void *p_node);
36
37 #endif //_MEMORY_POOL_H_

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1