demOS
 All Data Structures Files Modules Pages
ALLOC.H
Go to the documentation of this file.
1 /*------------------------------------------------------------------------------ --------------
2  Copyright J.Hubert 2015
3 
4  This file is part of demOS
5 
6  demOS is free software: you can redistribute it and/or modify it under the terms of
7  the GNU Lesser General Public License as published by the Free Software Foundation,
8  either version 3 of the License, or (at your option) any later version.
9 
10  demOS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY ;
11  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  See the GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License along with demOS.
15  If not, see <http://www.gnu.org/licenses/>.
16 -----------------------------------------------------------------------------------------------*/
17 
35 #ifndef ALLOC_H
36 #define ALLOC_H
37 
38 #include "DEMOSDK\BASTYPES.H"
39 
41 {
42  u8* buffer;
43  u32 size;
44 
45  u8* bufferEnd;
46 
47  u8* head;
48  u8* tail;
49  u8* last;
50 };
51 
52 void RINGallocatorInit (RINGallocator* _m, void* _buffer, u32 _size);
53 void* RINGallocatorAlloc (RINGallocator* _m, u32 _size);
54 void RINGallocatorFree (RINGallocator* _m, void* _address);
55 void RINGallocatorReset (RINGallocator* _m);
56 bool RINGallocatorIsEmpty (RINGallocator* _m);
57 
58 #ifdef DEMOS_DEBUG
59 
60 void RINGallocatorDump (RINGallocator* _m, FILE* _output);
61 u32 RINGallocatorList (RINGallocator* _m, void** _list, u32 _maxSize);
62 u32 RINGallocatorCheck (RINGallocator* _m);
63 
64 #else
65 
66 # define RINGallocatorDump(A, B)
67 # define RINGallocatorList(A, B, C)
68 # define RINGallocatorCheck(A)
69 
70 #endif
71 
72 
73 #ifdef DEMOS_UNITTEST
74 
75 void RINGallocatorUnitTest (void);
76 
77 #else
78 
79 # define RINGallocatorUnitTest()
80 
81 #endif
82 
83 
84 #endif
Definition: ALLOC.H:40
BASTYPES