aboutsummaryrefslogtreecommitdiff
path: root/sword2/memory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sword2/memory.cpp')
-rw-r--r--sword2/memory.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/sword2/memory.cpp b/sword2/memory.cpp
index c3268af953..bc7ee94345 100644
--- a/sword2/memory.cpp
+++ b/sword2/memory.cpp
@@ -17,9 +17,6 @@
* $Header$
*/
-// FIXME: We should investigate which problem all this memory managing stuff
-// is trying to solve. I'm not convinced that it's really needed.
-
// memory manager
// - "remember, it's not good to leave memory locked for a moment longer
// than necessary" Tony
@@ -45,17 +42,13 @@
namespace Sword2 {
-MemoryManager memory;
+MemoryManager *memory;
#define MEMORY_POOL (1024 * 12000)
// #define MEMDEBUG 1
-void MemoryManager::exit(void) {
- free(_freeMemman);
-}
-
-void MemoryManager::init(void) {
+MemoryManager::MemoryManager(void) {
uint32 j;
uint8 *memory_base;
@@ -91,6 +84,10 @@ void MemoryManager::init(void) {
_baseMemBlock = 0; // for now
}
+MemoryManager::~MemoryManager(void) {
+ free(_freeMemman);
+}
+
mem *MemoryManager::lowLevelAlloc(uint32 size, uint32 type, uint32 unique_id) {
// allocate a block of memory - locked or float
@@ -472,7 +469,7 @@ mem *MemoryManager::allocMemory(uint32 size, uint32 type, uint32 unique_id) {
while (virtualDefrag(size)) {
// trash the oldest closed resource
- if (!res_man.helpTheAgedOut()) {
+ if (!res_man->helpTheAgedOut()) {
error("alloc ran out of memory: size=%d type=%d unique_id=%d", size, type, unique_id);
}
}