Browse Source
Merge pull request #7091 from vonchenplus/fix_memroy_leak
Merge pull request #7091 from vonchenplus/fix_memroy_leak
core: Fix memory leaknce_cpp
committed by
GitHub
6 changed files with 114 additions and 9 deletions
-
1src/core/CMakeLists.txt
-
54src/core/hle/kernel/k_process.cpp
-
4src/core/hle/kernel/k_process.h
-
46src/core/hle/kernel/k_shared_memory_info.h
-
4src/core/hle/kernel/kernel.h
-
12src/core/hle/kernel/svc.cpp
@ -0,0 +1,46 @@ |
|||||
|
// Copyright 2021 yuzu Emulator Project |
||||
|
// Licensed under GPLv2 or any later version |
||||
|
// Refer to the license.txt file included. |
||||
|
|
||||
|
#pragma once |
||||
|
|
||||
|
#include <memory> |
||||
|
#include <string> |
||||
|
|
||||
|
#include <boost/intrusive/list.hpp> |
||||
|
|
||||
|
#include "common/assert.h" |
||||
|
#include "core/hle/kernel/slab_helpers.h" |
||||
|
|
||||
|
namespace Kernel { |
||||
|
|
||||
|
class KSharedMemory; |
||||
|
|
||||
|
class KSharedMemoryInfo final : public KSlabAllocated<KSharedMemoryInfo>, |
||||
|
public boost::intrusive::list_base_hook<> { |
||||
|
|
||||
|
public: |
||||
|
explicit KSharedMemoryInfo() = default; |
||||
|
|
||||
|
constexpr void Initialize(KSharedMemory* shmem) { |
||||
|
shared_memory = shmem; |
||||
|
} |
||||
|
|
||||
|
constexpr KSharedMemory* GetSharedMemory() const { |
||||
|
return shared_memory; |
||||
|
} |
||||
|
|
||||
|
constexpr void Open() { |
||||
|
++reference_count; |
||||
|
} |
||||
|
|
||||
|
constexpr bool Close() { |
||||
|
return (--reference_count) == 0; |
||||
|
} |
||||
|
|
||||
|
private: |
||||
|
KSharedMemory* shared_memory{}; |
||||
|
size_t reference_count{}; |
||||
|
}; |
||||
|
|
||||
|
} // namespace Kernel |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue