summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2021-04-16 16:33:24 +0430
committerAndreas Kling <kling@serenityos.org>2021-04-16 22:26:52 +0200
commite4412f1f599bea034dea608b8c7dcc4408d90066 (patch)
tree450ca59e2671a37c0aef9da0bf73667e60bb76ee /Kernel/FileSystem
parentfb814ee7202281e2fc623c686cc15a9ac6117152 (diff)
downloadserenity-e4412f1f599bea034dea608b8c7dcc4408d90066.zip
AK+Kernel: Make IntrusiveList capable of holding non-raw pointers
This should allow creating intrusive lists that have smart pointers, while remaining free (compared to the impl before this commit) when holding raw pointers :^) As a sidenote, this also adds a `RawPtr<T>` type, which is just equivalent to `T*`. Note that this does not actually use such functionality, but is only expected to pave the way for #6369, to replace NonnullRefPtrVector<T> with intrusive lists. As it is with zero-cost things, this makes the interface a bit less nice by requiring the type name of what an `IntrusiveListNode` holds (and optionally its container, if not RawPtr), and also requiring the type of the container (normally `RawPtr`) on the `IntrusiveList` instance.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r--Kernel/FileSystem/BlockBasedFileSystem.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/FileSystem/BlockBasedFileSystem.cpp b/Kernel/FileSystem/BlockBasedFileSystem.cpp
index 8bd2e70d00..93fcbff6f9 100644
--- a/Kernel/FileSystem/BlockBasedFileSystem.cpp
+++ b/Kernel/FileSystem/BlockBasedFileSystem.cpp
@@ -32,7 +32,7 @@
namespace Kernel {
struct CacheEntry {
- IntrusiveListNode list_node;
+ IntrusiveListNode<CacheEntry> list_node;
BlockBasedFS::BlockIndex block_index { 0 };
u8* data { nullptr };
bool has_data { false };
@@ -117,8 +117,8 @@ private:
BlockBasedFS& m_fs;
size_t m_entry_count { 10000 };
mutable HashMap<BlockBasedFS::BlockIndex, CacheEntry*> m_hash;
- mutable IntrusiveList<CacheEntry, &CacheEntry::list_node> m_clean_list;
- mutable IntrusiveList<CacheEntry, &CacheEntry::list_node> m_dirty_list;
+ mutable IntrusiveList<CacheEntry, RawPtr<CacheEntry>, &CacheEntry::list_node> m_clean_list;
+ mutable IntrusiveList<CacheEntry, RawPtr<CacheEntry>, &CacheEntry::list_node> m_dirty_list;
KBuffer m_cached_block_data;
KBuffer m_entries;
bool m_dirty { false };