kernel/ext2: Replace a manually allocated buffer with Buffer
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
54cc80f649
commit
7b88b9cea3
@ -91,19 +91,18 @@ namespace Ext2
|
|||||||
const usize inode_size = m_metadata.size;
|
const usize inode_size = m_metadata.size;
|
||||||
const usize block_size = m_fs->m_block_size;
|
const usize block_size = m_fs->m_block_size;
|
||||||
|
|
||||||
u8* const buf = (u8*)TRY(calloc_impl(block_size, 1));
|
auto buf = TRY(Buffer::create_sized(block_size));
|
||||||
auto guard = make_scope_guard([buf] { free_impl(buf); });
|
|
||||||
|
|
||||||
m_entries.clear();
|
m_entries.clear();
|
||||||
|
|
||||||
for (usize offset = 0; offset < inode_size; offset += block_size)
|
for (usize offset = 0; offset < inode_size; offset += block_size)
|
||||||
{
|
{
|
||||||
TRY(read(buf, offset, block_size));
|
TRY(read(buf.data(), offset, block_size));
|
||||||
|
|
||||||
usize dir_offset = 0;
|
usize dir_offset = 0;
|
||||||
while (dir_offset < block_size)
|
while (dir_offset < block_size)
|
||||||
{
|
{
|
||||||
auto& entry = *(Ext2::RawDirectoryEntry*)&buf[dir_offset];
|
auto& entry = *(Ext2::RawDirectoryEntry*)&buf.data()[dir_offset];
|
||||||
|
|
||||||
if (entry.inum != 0)
|
if (entry.inum != 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user