-
Notifications
You must be signed in to change notification settings - Fork 4
/
mempool.texi
121 lines (81 loc) · 3.56 KB
/
mempool.texi
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
@settitle MemPool library
@node Top
@top Top
The MemPool library is a stand-alone memory allocation library.
It is a block allocator library that uses a single fixed size memory
pool to allocate variable sized memory blocks, and exports functions
similar to malloc, realloc and free.
It is intended to either simulate low memory targets on GNU/Linux and
other systems, or to completely replace the system memory management.
It is based on the memory management code from the eCos operating
system, which was cut free from the environment so it can freely be
used on GNU/Linux and other systems.
It is re-published under the eCos licence.
@menu
* Building MemPool: How to build
* Using MemPool: How to use
* Copying: Copying
@end menu
@node How to build
Building MemPool:
GNU/Linux:
@smallexample
cd ./build
../MemPool/configure
make && make test
@end smallexample
Windows:
@smallexample
cd .\build
cmake ..\MemPool
cmake --build .
@end smallexample
@node How to use
Using MemPool:
The include file "mempool.h" contains all exported functions.
All functions in this library are thread-safe.
cyg_bool MemPool_init(cyg_uint32)
This function takes the requested size in bytes of the memory pool (up to 2GB)
and returns true on success false if not enough memory.
Call this function always first.
void MemPool_exit(void)
This function shuts the MemPool library down.
All previously allocated memory gets released to the O/S.
Call this function optionally on shutdown.
void MemPool_get_status(cyg_uint32 flags, struct Cyg_Mempool_Status* status)
This function returns current status about MemPool.
The parameter flags is CYG_MEMPOOL_STAT_ALL or a combination of CYG_MEMPOOL_STAT_XXX (see mpcommon.h).
*status is filled on return, and contains different usage statistics.
void* MemPool_Memory_Alloc_Func(cyg_uint32 size)
This function allocates a variable sized memory block out of the MemPool.
It can be used to replace the malloc function.
void* MemPool_Memory_ReAlloc_Func(void* mem, cyg_uint32 new_size)
This function reallocates a variable sized memory block out of the MemPool.
It can be used to replace the realloc function.
void MemPool_Memory_Free_Func(void* mem)
This function releases a variable sized memory block.
It can be used to replace the free function.
@node Copying
This file is part of the MemPool library.
Copyright @copyright{} 2017 Bernd Edlinger
MemPool is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3 or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, if other files instantiate templates or use
macros or inline functions from this file, or you compile this file
and link it with other works to produce a work based on this file,
this file does not by itself cause the resulting work to be covered by
the GNU General Public License. However the source code for this file
must still be made available in accordance with section (6) of the GNU
General Public License v3.
This exception does not invalidate any other reasons why a work based
on this file might be covered by the GNU General Public License.
@bye