From 9472043d808d929db938ee7c8edaf69811ac464d Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sat, 1 Sep 2018 01:16:37 -0500 Subject: [PATCH] [ox/fs] Remove completely pointless uses of ox_malloca --- deps/ox/src/ox/fs/filesystem2/filesystem.hpp | 32 ++++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/deps/ox/src/ox/fs/filesystem2/filesystem.hpp b/deps/ox/src/ox/fs/filesystem2/filesystem.hpp index 57ebbbe4..5eafd134 100644 --- a/deps/ox/src/ox/fs/filesystem2/filesystem.hpp +++ b/deps/ox/src/ox/fs/filesystem2/filesystem.hpp @@ -96,8 +96,8 @@ Error FileSystemTemplate::format() { oxReturnError(m_fs->format()); constexpr auto rootDirInode = MaxValue / 2; - auto rootDir = ox_malloca(sizeof(ox::fs::Directory), ox::fs::Directory, m_fs, rootDirInode); - oxReturnError(rootDir->init()); + Directory rootDir(m_fs, rootDirInode); + oxReturnError(rootDir.init()); FileSystemData fd; fd.rootDirInode = rootDirInode; @@ -116,8 +116,8 @@ Error FileSystemTemplate::mkdir(const char *path, bool recursive) { auto fd = fileSystemData(); if (fd.ok()) { oxTrace("ox::fs::FileSystemTemplate::mkdir") << "rootDirInode:" << fd.value.rootDirInode; - auto rootDir = ox_malloca(sizeof(ox::fs::Directory), ox::fs::Directory, m_fs, fd.value.rootDirInode); - return rootDir->mkdir(path, recursive); + Directory rootDir(m_fs, fd.value.rootDirInode); + return rootDir.mkdir(path, recursive); } else { oxLogError(fd.error); return fd.error; @@ -128,11 +128,11 @@ template Error FileSystemTemplate::move(const char *src, const char *dest) { auto fd = fileSystemData(); oxReturnError(fd.error); - auto rootDir = ox_malloca(sizeof(ox::fs::Directory), ox::fs::Directory, m_fs, fd.value.rootDirInode); - auto inode = rootDir->find(src); + Directory rootDir(m_fs, fd.value.rootDirInode); + auto inode = rootDir.find(src); oxReturnError(inode.error); - oxReturnError(rootDir->write(dest, inode)); - oxReturnError(rootDir->remove(src)); + oxReturnError(rootDir.write(dest, inode)); + oxReturnError(rootDir.remove(src)); return OxError(0); } @@ -140,8 +140,8 @@ template Error FileSystemTemplate::read(const char *path, void *buffer, std::size_t buffSize) { auto fd = fileSystemData(); oxReturnError(fd.error); - auto rootDir = ox_malloca(sizeof(ox::fs::Directory), ox::fs::Directory, m_fs, fd.value.rootDirInode); - auto inode = rootDir->find(path); + Directory rootDir(m_fs, fd.value.rootDirInode); + auto inode = rootDir.find(path); oxReturnError(inode.error); return read(inode, buffer, buffSize); } @@ -160,15 +160,15 @@ template Error FileSystemTemplate::remove(const char *path, bool recursive) { auto fd = fileSystemData(); oxReturnError(fd.error); - auto rootDir = ox_malloca(sizeof(ox::fs::Directory), ox::fs::Directory, m_fs, fd.value.rootDirInode); - auto inode = rootDir->find(path); + Directory rootDir(m_fs, fd.value.rootDirInode); + auto inode = rootDir.find(path); oxReturnError(inode.error); auto st = stat(inode); oxReturnError(st.error); if (st.value.fileType == FileType_NormalFile || recursive) { - if (auto err = rootDir->remove(path)) { + if (auto err = rootDir.remove(path)) { // removal failed, try putting the index back - oxLogError(rootDir->write(path, inode)); + oxLogError(rootDir.write(path, inode)); return err; } } else { @@ -255,8 +255,8 @@ template ValErr FileSystemTemplate::find(const char *path) { auto fd = fileSystemData(); oxReturnError(fd.error); - auto rootDir = ox_malloca(sizeof(ox::fs::Directory), ox::fs::Directory, m_fs, fd.value.rootDirInode); - auto inode = rootDir->find(path); + Directory rootDir(m_fs, fd.value.rootDirInode); + auto inode = rootDir.find(path); oxReturnError(inode.error); return inode.value; }