Browse Source

* Trully fixed the previous commits. (missing casts and incomplete sizes)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11996 54d463be-8e91-2dee-dedb-b68131a5f0ec
FlavioJS 17 years ago
parent
commit
94ad564ec8
2 changed files with 5 additions and 4 deletions
  1. 1 0
      Changelog-Trunk.txt
  2. 4 4
      src/common/malloc.c

+ 1 - 0
Changelog-Trunk.txt

@@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
 2007/12/30
 2007/12/30
+	* Trully fixed the previous commits. (missing cast and incomplete size)
 	* Made the memory manager set allocated memory to 0xCD and freed memory 
 	* Made the memory manager set allocated memory to 0xCD and freed memory 
 	  to 0xDD. The memory manager no longer 'hides' uses of freed memory.
 	  to 0xDD. The memory manager no longer 'hides' uses of freed memory.
 2007/12/29
 2007/12/29

+ 4 - 4
src/common/malloc.c

@@ -230,7 +230,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func )
 			unit_head_large_first = p;
 			unit_head_large_first = p;
 #ifdef DEBUG_MEMMGR
 #ifdef DEBUG_MEMMGR
 			// set allocated data to 0xCD (clean memory)
 			// set allocated data to 0xCD (clean memory)
-			memset(p + sizeof(struct unit_head_large) - sizeof(int), 0xCD, size);
+			memset((char *)p + sizeof(struct unit_head_large) - sizeof(int), 0xCD, size);
 #endif
 #endif
 			*(int*)((char*)p + sizeof(struct unit_head_large) - sizeof(int) + size) = 0xdeadbeaf;
 			*(int*)((char*)p + sizeof(struct unit_head_large) - sizeof(int) + size) = 0xdeadbeaf;
 			return (char *)p + sizeof(struct unit_head_large) - sizeof(int);
 			return (char *)p + sizeof(struct unit_head_large) - sizeof(int);
@@ -292,7 +292,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func )
 			head->file  = file;
 			head->file  = file;
 #ifdef DEBUG_MEMMGR
 #ifdef DEBUG_MEMMGR
 			// set allocated memory to 0xCD (clean memory)
 			// set allocated memory to 0xCD (clean memory)
-			memset(head + sizeof(struct unit_head) - sizeof(int), 0xCD, size);
+			memset((char *)head + sizeof(struct unit_head) - sizeof(int), 0xCD, size);
 #endif
 #endif
 			*(int*)((char*)head + sizeof(struct unit_head) - sizeof(int) + size) = 0xdeadbeaf;
 			*(int*)((char*)head + sizeof(struct unit_head) - sizeof(int) + size) = 0xdeadbeaf;
 			return (char *)head + sizeof(struct unit_head) - sizeof(int);
 			return (char *)head + sizeof(struct unit_head) - sizeof(int);
@@ -379,7 +379,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 			memmgr_usage_bytes -= head->size;
 			memmgr_usage_bytes -= head->size;
 #ifdef DEBUG_MEMMGR
 #ifdef DEBUG_MEMMGR
 			// set freed memory to 0xDD (dead memory)
 			// set freed memory to 0xDD (dead memory)
-			memset(ptr, 0xDD, size_hash - sizeof(struct unit_head_large) + sizeof(int) );
+			memset(ptr, 0xDD, head->size);
 #endif
 #endif
 			FREE(head_large,file,line,func);
 			FREE(head_large,file,line,func);
 		} else {
 		} else {
@@ -398,7 +398,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 			head->block = NULL;
 			head->block = NULL;
 #ifdef DEBUG_MEMMGR
 #ifdef DEBUG_MEMMGR
 			// set freed memory to 0xDD (dead memory)
 			// set freed memory to 0xDD (dead memory)
-			memset(ptr, 0xDD, head->size - sizeof(struct unit_head) + sizeof(int) );
+			memset(ptr, 0xDD, head->size);
 #endif
 #endif
 			memmgr_usage_bytes -= head->size;
 			memmgr_usage_bytes -= head->size;
 			if(--block->unit_used == 0) {
 			if(--block->unit_used == 0) {