diff options
author | FearlessTobi <thm.frey@gmail.com> | 2024-01-19 00:17:28 +0100 |
---|---|---|
committer | Liam <byteslice@airmail.cc> | 2024-01-25 22:43:53 +0100 |
commit | 975deb7528cd98460528553f6a9162bfbcd6cab1 (patch) | |
tree | d1419c7b50f428a3b0e3de15ca641887dcd94aed /src/core/file_sys/fs_memory_management.h | |
parent | fs: Add path class (diff) | |
download | yuzu-975deb7528cd98460528553f6a9162bfbcd6cab1.tar yuzu-975deb7528cd98460528553f6a9162bfbcd6cab1.tar.gz yuzu-975deb7528cd98460528553f6a9162bfbcd6cab1.tar.bz2 yuzu-975deb7528cd98460528553f6a9162bfbcd6cab1.tar.lz yuzu-975deb7528cd98460528553f6a9162bfbcd6cab1.tar.xz yuzu-975deb7528cd98460528553f6a9162bfbcd6cab1.tar.zst yuzu-975deb7528cd98460528553f6a9162bfbcd6cab1.zip |
Diffstat (limited to '')
-rw-r--r-- | src/core/file_sys/fs_memory_management.h | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/core/file_sys/fs_memory_management.h b/src/core/file_sys/fs_memory_management.h index 596143ba9..f03c6354b 100644 --- a/src/core/file_sys/fs_memory_management.h +++ b/src/core/file_sys/fs_memory_management.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -8,39 +8,31 @@ namespace FileSys { -std::mutex g_mutex; - constexpr size_t RequiredAlignment = alignof(u64); void* AllocateUnsafe(size_t size) { - /* Allocate. */ + // Allocate void* const ptr = ::operator new(size, std::align_val_t{RequiredAlignment}); - /* Check alignment. */ + // Check alignment ASSERT(Common::IsAligned(reinterpret_cast<uintptr_t>(ptr), RequiredAlignment)); - /* Return allocated pointer. */ + // Return allocated pointer return ptr; } void DeallocateUnsafe(void* ptr, size_t size) { - /* Deallocate the pointer. */ + // Deallocate the pointer ::operator delete(ptr, std::align_val_t{RequiredAlignment}); } void* Allocate(size_t size) { - /* Lock the allocator. */ - std::scoped_lock lk(g_mutex); - return AllocateUnsafe(size); } void Deallocate(void* ptr, size_t size) { - /* If the pointer is non-null, deallocate it. */ + // If the pointer is non-null, deallocate it if (ptr != nullptr) { - /* Lock the allocator. */ - std::scoped_lock lk(g_mutex); - DeallocateUnsafe(ptr, size); } } |