From 1bb0369223c2685148813c99fc7688265f90945c Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 17 Feb 2013 15:07:32 -0500 Subject: [PATCH] Native::NewPtr clear flag --- toolbox/mm.cpp | 17 +++++------------ toolbox/mm.h | 4 ++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/toolbox/mm.cpp b/toolbox/mm.cpp index 0d8b621..4ccdf9b 100644 --- a/toolbox/mm.cpp +++ b/toolbox/mm.cpp @@ -72,7 +72,7 @@ namespace MM namespace Native { - uint16_t NewPtr(uint32_t size, uint32_t &mcptr) + uint16_t NewPtr(uint32_t size, bool clear, uint32_t &mcptr) { // native pointers. @@ -86,6 +86,9 @@ namespace MM return memFullErr; } + if (clear) + std::memset(ptr, 0, size); + mcptr = ptr - Memory; PtrMap.emplace(std::make_pair(mcptr, size)); @@ -219,17 +222,7 @@ namespace MM uint32_t mcptr; uint16_t error; - error = Native::NewPtr(size, mcptr); - - if (!error) - { - if (clear && mcptr) - { - uint8_t *ptr = memoryPointer(mcptr); - std::memset(ptr, 0, size); - } - - } + error = Native::NewPtr(size, clear, mcptr); cpuSetAReg(0, mcptr); return SetMemError(error); diff --git a/toolbox/mm.h b/toolbox/mm.h index 7a2c7f2..5e6b487 100644 --- a/toolbox/mm.h +++ b/toolbox/mm.h @@ -17,8 +17,8 @@ namespace MM namespace Native { uint16_t NewHandle(uint32_t size, uint32_t &handle); - uint16_t NewPtr(uint32_t size, uint32_t &pointer); - + uint16_t NewPtr(uint32_t size, bool clear, uint32_t &pointer); + uint16_t DisposeHandle(uint32_t handle); uint16_t DisposePtr(uint32_t pointer); }