forked from fantaisie-software/purebasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpool.h
More file actions
79 lines (67 loc) · 1.65 KB
/
pool.h
File metadata and controls
79 lines (67 loc) · 1.65 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef MBA_POOL_H
#define MBA_POOL_H
/* pool - a container of recycleable objects
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef LIBMBA_API
#ifdef WIN32
# ifdef LIBMBA_EXPORTS
# define LIBMBA_API __declspec(dllexport)
# else /* LIBMBA_EXPORTS */
# define LIBMBA_API __declspec(dllimport)
# endif /* LIBMBA_EXPORTS */
#else /* WIN32 */
# define LIBMBA_API extern
#endif /* WIN32 */
#endif /* LIBMBA_API */
#include <stddef.h>
#include <mba/stack.h>
#include <mba/iterator.h>
#include <mba/allocator.h>
#define POOL_SIZE_MAX 2040
typedef del_fn rst_fn;
struct pool {
new_fn object_new;
del_fn object_del;
rst_fn object_rst;
void *context;
size_t size;
int flags;
unsigned char *bitset;
unsigned int max_size;
unsigned int unused;
struct stack stk;
struct allocator *al;
};
LIBMBA_API int pool_create(struct pool *p,
unsigned int max_size,
new_fn object_new,
del_fn object_del,
rst_fn object_rst,
void *context,
size_t size,
int undo,
struct allocator *al);
LIBMBA_API int pool_destroy(struct pool *p);
LIBMBA_API struct pool *pool_new(unsigned int max_size,
new_fn object_new,
del_fn object_del,
rst_fn object_rst,
void *context,
size_t size,
int flags,
struct allocator *al);
LIBMBA_API int pool_del(struct pool *p);
LIBMBA_API int pool_clean(struct pool *p);
LIBMBA_API void *pool_get(struct pool *p);
LIBMBA_API int pool_release(struct pool *p, void *data);
LIBMBA_API unsigned int pool_size(struct pool *p);
LIBMBA_API unsigned int pool_unused(struct pool *p);
LIBMBA_API void pool_iterate(void *p, iter_t *iter);
LIBMBA_API void *pool_next(void *p, iter_t *iter);
#ifdef __cplusplus
}
#endif
#endif /* MBA_POOL_H */