[ox/fs] Replace some reinterpret_casts with placement-new
This commit is contained in:
parent
cdd1de89f8
commit
a0c645f25c
8
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
8
deps/ox/src/ox/fs/filesystem/directory.hpp
vendored
@ -150,7 +150,7 @@ Error Directory<FileStore, InodeId_t>::mkdir(PathIterator path, bool parents, Fi
|
|||||||
oxTrace("ox::fs::Directory::mkdir") << path.fullPath();
|
oxTrace("ox::fs::Directory::mkdir") << path.fullPath();
|
||||||
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
||||||
if (nameBuff == nullptr) {
|
if (nameBuff == nullptr) {
|
||||||
nameBuff = reinterpret_cast<FileName*>(ox_alloca(sizeof(FileName)));
|
nameBuff = new (ox_alloca(sizeof(FileName))) FileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine if already exists
|
// determine if already exists
|
||||||
@ -193,7 +193,7 @@ template<typename FileStore, typename InodeId_t>
|
|||||||
Error Directory<FileStore, InodeId_t>::write(PathIterator path, InodeId_t inode, FileName *nameBuff) noexcept {
|
Error Directory<FileStore, InodeId_t>::write(PathIterator path, InodeId_t inode, FileName *nameBuff) noexcept {
|
||||||
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
||||||
if (nameBuff == nullptr) {
|
if (nameBuff == nullptr) {
|
||||||
nameBuff = reinterpret_cast<FileName*>(ox_alloca(sizeof(FileName)));
|
nameBuff = new (ox_alloca(sizeof(FileName))) FileName;
|
||||||
}
|
}
|
||||||
auto name = nameBuff;
|
auto name = nameBuff;
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ template<typename FileStore, typename InodeId_t>
|
|||||||
Error Directory<FileStore, InodeId_t>::remove(PathIterator path, FileName *nameBuff) noexcept {
|
Error Directory<FileStore, InodeId_t>::remove(PathIterator path, FileName *nameBuff) noexcept {
|
||||||
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
||||||
if (nameBuff == nullptr) {
|
if (nameBuff == nullptr) {
|
||||||
nameBuff = reinterpret_cast<FileName*>(ox_alloca(sizeof(FileName)));
|
nameBuff = new (ox_alloca(sizeof(FileName))) FileName;
|
||||||
}
|
}
|
||||||
auto &name = *nameBuff;
|
auto &name = *nameBuff;
|
||||||
oxReturnError(path.get(&name));
|
oxReturnError(path.get(&name));
|
||||||
@ -339,7 +339,7 @@ template<typename FileStore, typename InodeId_t>
|
|||||||
Result<typename FileStore::InodeId_t> Directory<FileStore, InodeId_t>::find(PathIterator path, FileName *nameBuff) const noexcept {
|
Result<typename FileStore::InodeId_t> Directory<FileStore, InodeId_t>::find(PathIterator path, FileName *nameBuff) const noexcept {
|
||||||
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
// reuse nameBuff if it has already been allocated, as it is a rather large variable
|
||||||
if (nameBuff == nullptr) {
|
if (nameBuff == nullptr) {
|
||||||
nameBuff = reinterpret_cast<FileName*>(ox_alloca(sizeof(FileName)));
|
nameBuff = new (ox_alloca(sizeof(FileName))) FileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine if already exists
|
// determine if already exists
|
||||||
|
Loading…
x
Reference in New Issue
Block a user