Native::NewPtr clear flag

This commit is contained in:
Kelvin Sherlock 2013-02-17 15:07:32 -05:00
parent 4f4fde9cfb
commit 1bb0369223
2 changed files with 7 additions and 14 deletions

View File

@ -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);

View File

@ -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);
}