diff options
| author | Paul Gilbert | 2012-05-05 00:29:44 +1000 | 
|---|---|---|
| committer | Paul Gilbert | 2012-05-05 00:29:44 +1000 | 
| commit | a511b828e416c657e01a86e931016d4a4b7d49b9 (patch) | |
| tree | 0ff9f981c3da69efbd6b54bbde9753fdee175504 /engines/tony/mpal/memory.cpp | |
| parent | 5ab27cdacd0b93e4c1de613833edf1894820d2b4 (diff) | |
| download | scummvm-rg350-a511b828e416c657e01a86e931016d4a4b7d49b9.tar.gz scummvm-rg350-a511b828e416c657e01a86e931016d4a4b7d49b9.tar.bz2 scummvm-rg350-a511b828e416c657e01a86e931016d4a4b7d49b9.zip | |
TONY: Initial fixes for some of the Valgrind reported errors
Diffstat (limited to 'engines/tony/mpal/memory.cpp')
| -rw-r--r-- | engines/tony/mpal/memory.cpp | 12 | 
1 files changed, 9 insertions, 3 deletions
| diff --git a/engines/tony/mpal/memory.cpp b/engines/tony/mpal/memory.cpp index de6e918a38..166e3598f8 100644 --- a/engines/tony/mpal/memory.cpp +++ b/engines/tony/mpal/memory.cpp @@ -21,6 +21,7 @@   *   */ +#include "common/algorithm.h"  #include "common/textconsole.h"  #include "tony/mpal/memory.h" @@ -77,8 +78,13 @@ MemoryManager::~MemoryManager() {   * Allocates a new memory block   * @returns					Returns a MemoryItem instance for the new block   */ -MemoryItem &MemoryManager::allocate(uint32 size) { +MemoryItem &MemoryManager::allocate(uint32 size, uint flags) {  	MemoryItem *newItem = new MemoryItem(size); +	if ((flags & GMEM_ZEROINIT) != 0) { +		byte *dataP = (byte *)newItem->DataPointer(); +		Common::fill(dataP, dataP + size, 0); +	} +  	_memoryBlocks.push_back(newItem);  	return *newItem; @@ -88,8 +94,8 @@ MemoryItem &MemoryManager::allocate(uint32 size) {   * Allocates a new memory block and returns it's data pointer   * @returns					Data pointer to allocated block   */ -HGLOBAL MemoryManager::alloc(uint32 size) { -	MemoryItem &newItem = allocate(size); +HGLOBAL MemoryManager::alloc(uint32 size, uint flags) { +	MemoryItem &newItem = allocate(size, flags);  	return (HGLOBAL)newItem.DataPointer();  } | 
