- Add assertions to enforce that objects are of the correct kind and
  have been allocated.

- Make destructors check if objects have been allocated before
  deleting.

- Operations that require a non-NullDevice return failure if given a
  NullDevice.

- Use static_cast rather than reinterpret_cast when cohersing from a
  base class to a derived class.

Change-Id: I02ee0ea9d7982fd7ca29d49c9b02cfae111b7127
Этот коммит содержится в:
Tony Tye
2021-01-10 02:09:00 +00:00
родитель 001fd66cac
Коммит e5431676d4
11 изменённых файлов: 96 добавлений и 13 удалений
+9 -4
Просмотреть файл
@@ -268,10 +268,14 @@ Device::Device()
}
Device::~Device() {
CondLog((vaCacheMap_ != nullptr) && (vaCacheMap_->size() != 0),
"Application didn't unmap all host memory!");
delete vaCacheMap_;
delete vaCacheAccess_;
if (vaCacheMap_) {
CondLog(vaCacheMap_->size() != 0, "Application didn't unmap all host memory!");
delete vaCacheMap_;
}
if (vaCacheAccess_) {
delete vaCacheAccess_;
}
// Destroy device settings
if (settings_ != nullptr) {
@@ -297,6 +301,7 @@ bool Device::ValidateComgr() {
}
bool Device::create() {
assert(!vaCacheAccess_ && !vaCacheMap_);
vaCacheAccess_ = new amd::Monitor("VA Cache Ops Lock", true);
if (nullptr == vaCacheAccess_) {
return false;