add resource bit to handle info

This commit is contained in:
Kelvin Sherlock 2013-08-03 19:17:15 -04:00
parent 37b45e66ab
commit bdce056449
3 changed files with 27 additions and 1 deletions

View File

@ -61,9 +61,10 @@ namespace
uint32_t size;
bool locked;
bool purgeable;
bool resource;
HandleInfo(uint32_t a = 0, uint32_t s = 0) :
address(a), size(s), locked(false), purgeable(false)
address(a), size(s), locked(false), purgeable(false), resource(false)
{}
};
@ -334,6 +335,27 @@ namespace MM
handleSize = iter->second.size;
return SetMemError(0);
}
uint16_t HSetRBit(uint32_t handle)
{
const auto iter = HandleMap.find(handle);
if (iter == HandleMap.end()) return SetMemError(MacOS::memWZErr);
auto &info = iter->second;
info.resource = true;
return SetMemError(0);
}
uint16_t HClrRBit(uint32_t handle)
{
const auto iter = HandleMap.find(handle);
if (iter == HandleMap.end()) return SetMemError(MacOS::memWZErr);
auto &info = iter->second;
info.resource = false;
return SetMemError(0);
}
}

View File

@ -21,6 +21,9 @@ namespace MM
uint16_t DisposePtr(uint32_t pointer);
uint16_t GetHandleSize(uint32_t handle, uint32_t &handleSize);
uint16_t HSetRBit(uint32_t handle);
uint16_t HClrRBit(uint32_t handle);
}
bool Init(uint8_t *memory, uint32_t memorySize, uint32_t reserved);

View File

@ -161,6 +161,7 @@ namespace RM
::ReleaseResource(nativeHandle);
return SetResError(error);
}
MM::Native::HSetRBit(theHandle);
if (size)
std::memcpy(memoryPointer(ptr), *(void **)nativeHandle, size);