mbed OS5

Fork of UIPEthernet by Zoltan Hudak

Committer:
hudakz
Date:
Sun Mar 08 20:26:56 2015 +0000
Revision:
4:d774541a34da
Parent:
3:5b17e4656dd0
Child:
8:4acb22344932
Version 1.09 (fixed leaking client-data caused by race-condition on remote close)

Who changed what in which revision?

UserRevisionLine numberNew 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 3:5b17e4656dd0 20 #define MEMPOOL_H
hudakz 3:5b17e4656dd0 21
hudakz 3:5b17e4656dd0 22 #include <inttypes.h>
hudakz 3:5b17e4656dd0 23
hudakz 3:5b17e4656dd0 24 #define POOLSTART 0
hudakz 3:5b17e4656dd0 25 #define NOBLOCK 0
hudakz 3:5b17e4656dd0 26
hudakz 3:5b17e4656dd0 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
hudakz 3:5b17e4656dd0 36 class MemoryPool
hudakz 3:5b17e4656dd0 37 {
hudakz 3:5b17e4656dd0 38 #ifdef MEMPOOLTEST_H
hudakz 3:5b17e4656dd0 39 friend class MemoryPoolTest;
hudakz 3:5b17e4656dd0 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