ScummVM API documentation
memory.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1994-1998 Revolution Software Ltd.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 
24 #ifndef SWORD2_MEMORY_H
25 #define SWORD2_MEMORY_H
26 
27 enum {
28  MAX_MEMORY_BLOCKS = 999
29 };
30 
31 namespace Sword2 {
32 
33 struct MemBlock {
34  int16 id;
35  int16 uid;
36  byte *ptr;
37  uint32 size;
38 };
39 
41 private:
42  MemBlock *_memBlocks;
43  MemBlock **_memBlockIndex;
44  int16 _numBlocks;
45 
46  uint32 _totAlloc;
47 
48  int16 *_idStack;
49  int16 _idStackPtr;
50 
51  int16 findExactPointerInIndex(byte *ptr);
52  int16 findPointerInIndex(byte *ptr);
53  int16 findInsertionPointInIndex(byte *ptr);
54 
55 public:
56  MemoryManager();
57  ~MemoryManager();
58 
59  int16 getNumBlocks() { return _numBlocks; }
60  uint32 getTotAlloc() { return _totAlloc; }
61  MemBlock *getMemBlocks() { return _memBlocks; }
62 
63  int32 encodePtr(byte *ptr);
64  byte *decodePtr(int32 n);
65 
66  byte *memAlloc(uint32 size, int16 uid);
67  void memFree(byte *ptr);
68 };
69 
70 } // End of namespace Sword2
71 
72 #endif
Definition: animation.h:37
Definition: memory.h:40
Definition: memory.h:33