mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-28 22:07:54 -05:00
scope_exit: Make constexpr
Allows the use of the macro in constexpr-contexts. Also avoids some potential problems when nesting braces inside it.
This commit is contained in:
@ -3,6 +3,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
constexpr inline size_t EntryNameLengthMax = 0x300;
|
||||
|
@ -447,7 +447,7 @@ public:
|
||||
char* replacement_path = nullptr;
|
||||
size_t replacement_path_size = 0;
|
||||
|
||||
SCOPE_EXIT({
|
||||
SCOPE_EXIT {
|
||||
if (replacement_path != nullptr) {
|
||||
if (std::is_constant_evaluated()) {
|
||||
delete[] replacement_path;
|
||||
@ -455,7 +455,7 @@ public:
|
||||
Deallocate(replacement_path, replacement_path_size);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Perform path replacement, if necessary
|
||||
if (IsParentDirectoryPathReplacementNeeded(cur_path)) {
|
||||
@ -1102,8 +1102,8 @@ public:
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
static Result Normalize(char* dst, size_t dst_size, const char* path, size_t path_len,
|
||||
const PathFlags& flags) {
|
||||
static constexpr Result Normalize(char* dst, size_t dst_size, const char* path, size_t path_len,
|
||||
const PathFlags& flags) {
|
||||
// Use StringTraits names for remainder of scope
|
||||
using namespace StringTraits;
|
||||
|
||||
@ -1199,7 +1199,7 @@ public:
|
||||
const size_t replaced_src_len = path_len - (src - path);
|
||||
|
||||
char* replaced_src = nullptr;
|
||||
SCOPE_EXIT({
|
||||
SCOPE_EXIT {
|
||||
if (replaced_src != nullptr) {
|
||||
if (std::is_constant_evaluated()) {
|
||||
delete[] replaced_src;
|
||||
@ -1207,7 +1207,7 @@ public:
|
||||
Deallocate(replaced_src, replaced_src_len);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (std::is_constant_evaluated()) {
|
||||
replaced_src = new char[replaced_src_len];
|
||||
|
@ -36,7 +36,9 @@ Result HierarchicalSha256Storage::Initialize(VirtualFile* base_storages, s32 lay
|
||||
// Get the base storage size.
|
||||
m_base_storage_size = base_storages[2]->GetSize();
|
||||
{
|
||||
auto size_guard = SCOPE_GUARD({ m_base_storage_size = 0; });
|
||||
auto size_guard = SCOPE_GUARD {
|
||||
m_base_storage_size = 0;
|
||||
};
|
||||
R_UNLESS(m_base_storage_size <= static_cast<s64>(HashSize)
|
||||
<< m_log_size_ratio << m_log_size_ratio,
|
||||
ResultHierarchicalSha256BaseStorageTooLarge);
|
||||
|
@ -98,7 +98,9 @@ Loader::ResultStatus ProgramMetadata::Load(VirtualFile file) {
|
||||
|
||||
Loader::ResultStatus ProgramMetadata::Reload(VirtualFile file) {
|
||||
const u64 original_program_id = aci_header.title_id;
|
||||
SCOPE_EXIT({ aci_header.title_id = original_program_id; });
|
||||
SCOPE_EXIT {
|
||||
aci_header.title_id = original_program_id;
|
||||
};
|
||||
|
||||
return this->Load(file);
|
||||
}
|
||||
|
Reference in New Issue
Block a user