mbed OS5
Fork of UIPEthernet by
utility/mempool.h@9:e55652bed36c, 2017-08-06 (annotated)
- Committer:
- pilotak
- Date:
- Sun Aug 06 16:01:26 2017 +0000
- Revision:
- 9:e55652bed36c
- Parent:
- 8:4acb22344932
mBed OS5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hudakz | 3:5b17e4656dd0 | 1 | /* |
hudakz | 3:5b17e4656dd0 | 2 | mempool.h - sleek implementation of a memory pool |
hudakz | 3:5b17e4656dd0 | 3 | Copyright (c) 2013 Norbert Truchsess <norbert.truchsess@t-online.de> |
hudakz | 3:5b17e4656dd0 | 4 | All rights reserved. |
hudakz | 3:5b17e4656dd0 | 5 | |
hudakz | 3:5b17e4656dd0 | 6 | This program is free software: you can redistribute it and/or modify |
hudakz | 3:5b17e4656dd0 | 7 | it under the terms of the GNU General Public License as published by |
hudakz | 3:5b17e4656dd0 | 8 | the Free Software Foundation, either version 3 of the License, or |
hudakz | 3:5b17e4656dd0 | 9 | (at your option) any later version. |
hudakz | 3:5b17e4656dd0 | 10 | |
hudakz | 3:5b17e4656dd0 | 11 | This program is distributed in the hope that it will be useful, |
hudakz | 3:5b17e4656dd0 | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
hudakz | 3:5b17e4656dd0 | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
hudakz | 3:5b17e4656dd0 | 14 | GNU General Public License for more details. |
hudakz | 3:5b17e4656dd0 | 15 | |
hudakz | 3:5b17e4656dd0 | 16 | You should have received a copy of the GNU General Public License |
hudakz | 3:5b17e4656dd0 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
hudakz | 3:5b17e4656dd0 | 18 | */ |
hudakz | 3:5b17e4656dd0 | 19 | #ifndef MEMPOOL_H |
hudakz | 8:4acb22344932 | 20 | #define MEMPOOL_H |
hudakz | 3:5b17e4656dd0 | 21 | |
hudakz | 8:4acb22344932 | 22 | #include <inttypes.h> |
hudakz | 3:5b17e4656dd0 | 23 | |
hudakz | 8:4acb22344932 | 24 | #define POOLSTART 0 |
hudakz | 8:4acb22344932 | 25 | #define NOBLOCK 0 |
hudakz | 3:5b17e4656dd0 | 26 | |
hudakz | 8:4acb22344932 | 27 | #include "mempool_conf.h" |
hudakz | 3:5b17e4656dd0 | 28 | |
hudakz | 3:5b17e4656dd0 | 29 | struct memblock |
hudakz | 3:5b17e4656dd0 | 30 | { |
hudakz | 3:5b17e4656dd0 | 31 | memaddress begin; |
hudakz | 3:5b17e4656dd0 | 32 | memaddress size; |
hudakz | 3:5b17e4656dd0 | 33 | memhandle nextblock; |
hudakz | 3:5b17e4656dd0 | 34 | }; |
hudakz | 3:5b17e4656dd0 | 35 | |
pilotak | 9:e55652bed36c | 36 | class myMemoryPool |
hudakz | 3:5b17e4656dd0 | 37 | { |
hudakz | 8:4acb22344932 | 38 | #ifdef MEMPOOLTEST_H |
hudakz | 3:5b17e4656dd0 | 39 | friend class MemoryPoolTest; |
hudakz | 8:4acb22344932 | 40 | #endif |
hudakz | 3:5b17e4656dd0 | 41 | protected: |
hudakz | 4:d774541a34da | 42 | static struct memblock blocks[MEMPOOL_NUM_MEMBLOCKS + 1]; |
hudakz | 3:5b17e4656dd0 | 43 | public: |
hudakz | 4:d774541a34da | 44 | static void init(void); |
hudakz | 4:d774541a34da | 45 | static memhandle allocBlock(memaddress); |
hudakz | 4:d774541a34da | 46 | static void freeBlock(memhandle); |
hudakz | 4:d774541a34da | 47 | static void resizeBlock(memhandle handle, memaddress position); |
hudakz | 4:d774541a34da | 48 | static void resizeBlock(memhandle handle, memaddress position, memaddress size); |
hudakz | 4:d774541a34da | 49 | static memaddress blockSize(memhandle); |
hudakz | 3:5b17e4656dd0 | 50 | }; |
hudakz | 3:5b17e4656dd0 | 51 | #endif |