aboutsummaryrefslogtreecommitdiff
path: root/sword2/memory.h
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-09-30 14:37:42 +0000
committerTorbjörn Andersson2003-09-30 14:37:42 +0000
commitda1b4f1e3627a6baf242457cb9c69328a7f899f0 (patch)
treeb523a0e56d0122620062b206fc02d642f2c66b85 /sword2/memory.h
parent457f888ea7c6dc7cefc7491c5fc74b057f7ef1eb (diff)
downloadscummvm-rg350-da1b4f1e3627a6baf242457cb9c69328a7f899f0.tar.gz
scummvm-rg350-da1b4f1e3627a6baf242457cb9c69328a7f899f0.tar.bz2
scummvm-rg350-da1b4f1e3627a6baf242457cb9c69328a7f899f0.zip
Moved the memory manager functions into an object of its own (and enabled
debugging levels). This needs further cleanups, but I believe I have reached a stable point where I can commit it without too much anxiety. svn-id: r10502
Diffstat (limited to 'sword2/memory.h')
-rw-r--r--sword2/memory.h55
1 files changed, 41 insertions, 14 deletions
diff --git a/sword2/memory.h b/sword2/memory.h
index 6a1fa6c7bb..5c83ee12dd 100644
--- a/sword2/memory.h
+++ b/sword2/memory.h
@@ -60,19 +60,46 @@ typedef struct {
#define UID_savegame_buffer 0xfffffff6
#define UID_restoregame_buffer 0xfffffff5
-void Init_memory_manager(void);
-void Close_memory_manager(void); // Tony2Oct96
-mem *Twalloc(uint32 size, uint32 type, uint32 unique_id); // high level
-void Free_mem(mem *block);
-void Float_mem(mem *block);
-void Lock_mem(mem *block);
-void Mem_debug(void);
-void Visual_mem_display(void);
-int32 Defrag_mem(uint32 req_size); // Tony10Apr96
-
-extern uint32 total_blocks;
-extern uint32 base_mem_block;
-extern mem mem_list[MAX_mem_blocks];
-extern uint32 total_free_memory;
+class MemoryManager {
+private:
+ // Address of init malloc to be freed later
+ uint8 *_freeMemman;
+
+ uint32 _totalFreeMemory;
+ uint32 _totalBlocks;
+
+ // Start position of the defragger as indicated by its sister,
+ // VirtualDefrag.
+ int32 _suggestedStart;
+
+ mem *lowLevelAlloc(uint32 size, uint32 type, uint32 unique_id);
+ int32 defragMemory(uint32 req_size);
+
+ // Used to determine if the required size can be obtained if the
+ // defragger is allowed to run.
+ int32 virtualDefrag(uint32 size);
+
+ // Debugging functions
+ void debugMemory(void);
+ const char *fetchOwner(uint32 uid);
+ void memoryString(char *string);
+
+public:
+ // List of defined memory handles - each representing a block of memory
+ mem _memList[MAX_mem_blocks];
+ uint32 _baseMemBlock;
+
+ void init(void);
+ void exit(void);
+ mem *allocMemory(uint32 size, uint32 type, uint32 unique_id);
+ void freeMemory(mem *block);
+ void floatMemory(mem *block);
+ void lockMemory(mem *block);
+
+ // Debugging function
+ void displayMemory(void);
+};
+
+extern MemoryManager memory;
#endif