[Scummvm-cvs-logs] SF.net SVN: scummvm: [24274] scummvm/branches/branch-0-9-0/backends/gp32/ gp32std_memory.cpp

wonst719 at users.sourceforge.net wonst719 at users.sourceforge.net
Wed Oct 11 15:57:14 CEST 2006


Revision: 24274
          http://svn.sourceforge.net/scummvm/?rev=24274&view=rev
Author:   wonst719
Date:     2006-10-11 06:57:09 -0700 (Wed, 11 Oct 2006)

Log Message:
-----------
Fix memory management

Modified Paths:
--------------
    scummvm/branches/branch-0-9-0/backends/gp32/gp32std_memory.cpp

Modified: scummvm/branches/branch-0-9-0/backends/gp32/gp32std_memory.cpp
===================================================================
--- scummvm/branches/branch-0-9-0/backends/gp32/gp32std_memory.cpp	2006-10-11 13:53:30 UTC (rev 24273)
+++ scummvm/branches/branch-0-9-0/backends/gp32/gp32std_memory.cpp	2006-10-11 13:57:09 UTC (rev 24274)
@@ -29,11 +29,11 @@
 #include "common/system.h"
 #include "backends/intern.h"
 
-#include "base/engine.h"
+#include "engines/engine.h"
 
-#include "backends/gp32/gp32std.h"
-#include "backends/gp32/gp32std_grap.h"
-#include "backends/gp32/gp32std_memory.h"
+#include "gp32std.h"
+#include "gp32std_grap.h"
+#include "gp32std_memory.h"
 
 /////////////////////
 //Memory management
@@ -122,8 +122,10 @@
 			}
 			blk++;
 		}
-		if(i == prevBlock)
-			return NULL;
+		if(i == prevBlock) {
+			prevBlock = 0;
+			return gm_malloc(size);
+		}
 	}
 
 	byte *ptr = userMem + (i * USER_BLOCK_SIZE);
@@ -139,11 +141,13 @@
 
 void MemBlock::deleteBlock(void *dstBlock)
 {
+	// Faster method
 	uint32 np = (uint32) dstBlock - (uint32) userMem;
 
 	if ((np / USER_BLOCK_SIZE) * USER_BLOCK_SIZE != np) {
 		gm_free(dstBlock);
 //		warning("wrong block! (%d / %d)", (np / USER_BLOCK_SIZE) * USER_BLOCK_SIZE, np);
+		return;
 	}
 	int i = np / USER_BLOCK_SIZE;
 	if (i > NUM_BLOCK) {
@@ -201,10 +205,6 @@
 	int allocSize = ALIGNED_SIZE(size) + sizeof(uint32) + sizeof(uint32);
 	if (allocSize <= USER_BLOCK_SIZE) {
 		np = (uint32) MemBlock::addBlock(allocSize);
-		if (!np) {
-//			GPDEBUG("falling back to gm_malloc");
-			np = (uint32) gm_malloc(allocSize);
-		}
 	} else {
 		np = (uint32) gm_malloc(allocSize);
 	}
@@ -276,9 +276,9 @@
 int gUsedMem = 1024 * 1024;
 
 //#define CLEAN_MEMORY_WITH_0xE7
-#define CHECK_USED_MEMORY
-#define CHECK_NEW_TIME
-#define CHECK_NEW_SIZE
+//#define CHECK_USED_MEMORY
+//#define CHECK_NEW_TIME
+//#define CHECK_NEW_SIZE
 
 void *operator new(size_t size) {
 #if defined(CHECK_NEW_TIME)


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list