fix: fail L0 device creation when invalid state save area header was delivered

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2024-08-22 15:05:35 +00:00
committed by Compute-Runtime-Automation
parent 70bb654c15
commit 5b51146673
3 changed files with 51 additions and 3 deletions

View File

@@ -1,11 +1,12 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <memory>
template <typename T>
class VariableBackup {
@@ -36,3 +37,20 @@ class VariableBackup {
T oldValue;
T *pValue;
};
template <typename T>
class NonCopyableVariableBackup {
public:
NonCopyableVariableBackup(T *ptr, T &&newValue) : pValue(ptr) {
oldValue = std::move(*ptr);
*pValue = std::move(newValue);
}
~NonCopyableVariableBackup() {
*pValue = std::move(oldValue);
}
private:
T oldValue;
T *pValue;
};