Skip to content

Commit

Permalink
Kernel: More use of NonnullRefPtrVector in the kernel.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jun 27, 2019
1 parent 3bd47a2 commit 75a24c3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Kernel/FileSystem/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ void FS::sync()
{
Inode::sync();

Vector<NonnullRefPtr<FS>, 32> fses;
NonnullRefPtrVector<FS, 32> fses;
{
InterruptDisabler disabler;
for (auto& it : all_fses())
fses.append(*it.value);
}

for (auto fs : fses)
fs->flush_writes();
for (auto& fs : fses)
fs.flush_writes();
}

void FS::lock_all()
Expand Down
7 changes: 4 additions & 3 deletions Kernel/FileSystem/Inode.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <AK/NonnullRefPtrVector.h>
#include <AK/StringBuilder.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Net/LocalSocket.h>
Expand All @@ -13,7 +14,7 @@ HashTable<Inode*>& all_inodes()

void Inode::sync()
{
Vector<NonnullRefPtr<Inode>, 32> inodes;
NonnullRefPtrVector<Inode, 32> inodes;
{
InterruptDisabler disabler;
for (auto* inode : all_inodes()) {
Expand All @@ -23,8 +24,8 @@ void Inode::sync()
}

for (auto& inode : inodes) {
ASSERT(inode->is_metadata_dirty());
inode->flush_metadata();
ASSERT(inode.is_metadata_dirty());
inode.flush_metadata();
}
}

Expand Down
10 changes: 5 additions & 5 deletions Kernel/FileSystem/VirtualFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ KResultOr<NonnullRefPtr<Custody>> VFS::resolve_path(StringView path, Custody& ba
auto parts = path.split_view('/');
InodeIdentifier crumb_id;

Vector<NonnullRefPtr<Custody>, 32> custody_chain;
NonnullRefPtrVector<Custody, 32> custody_chain;

if (path[0] == '/') {
custody_chain.append(root_custody());
Expand Down Expand Up @@ -661,9 +661,9 @@ KResultOr<NonnullRefPtr<Custody>> VFS::resolve_path(StringView path, Custody& ba

auto& part = parts[i];
if (part.is_empty())
break;
break;

auto current_parent = custody_chain.last();
auto& current_parent = custody_chain.last();
crumb_id = crumb_inode->lookup(part);
if (!crumb_id.is_valid())
return KResult(-ENOENT);
Expand All @@ -678,7 +678,7 @@ KResultOr<NonnullRefPtr<Custody>> VFS::resolve_path(StringView path, Custody& ba
crumb_inode = get_inode(crumb_id);
ASSERT(crumb_inode);

custody_chain.append(Custody::get_or_create(custody_chain.last().ptr(), part, *crumb_inode));
custody_chain.append(Custody::get_or_create(&custody_chain.last(), part, *crumb_inode));

metadata = crumb_inode->metadata();
if (metadata.is_directory()) {
Expand All @@ -702,7 +702,7 @@ KResultOr<NonnullRefPtr<Custody>> VFS::resolve_path(StringView path, Custody& ba
auto symlink_target = resolve_path(
StringView(symlink_contents.pointer(),
symlink_contents.size()),
*current_parent,
current_parent,
parent_custody,
options);

Expand Down

0 comments on commit 75a24c3

Please sign in to comment.