mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-25 22:14:37 +00:00
Remove unused SmartHeap class
This commit is contained in:
parent
e2e9cfe84d
commit
31dca2e9a6
@ -1,25 +0,0 @@
|
||||
#include <memory.hpp>
|
||||
|
||||
namespace Memory
|
||||
{
|
||||
SmartHeap::SmartHeap(size_t Size, VirtualMemoryArea *vma)
|
||||
{
|
||||
if (vma)
|
||||
{
|
||||
this->vma = vma;
|
||||
this->Object = vma->RequestPages(TO_PAGES(Size));
|
||||
}
|
||||
else
|
||||
this->Object = kmalloc(Size);
|
||||
this->ObjectSize = Size;
|
||||
memset(this->Object, 0, Size);
|
||||
}
|
||||
|
||||
SmartHeap::~SmartHeap()
|
||||
{
|
||||
if (this->vma)
|
||||
this->vma->FreePages(this->Object, TO_PAGES(this->ObjectSize));
|
||||
else
|
||||
kfree(this->Object);
|
||||
}
|
||||
}
|
@ -105,22 +105,22 @@ namespace Execute
|
||||
std::vector<Elf64_Phdr> PhdrINTERP = ELFGetSymbolType_x86_64(fd, PT_INTERP);
|
||||
foreach (auto Interp in PhdrINTERP)
|
||||
{
|
||||
Memory::SmartHeap InterpreterPath = Memory::SmartHeap(256);
|
||||
fd->Read(InterpreterPath, 256, Interp.p_offset);
|
||||
std::string interpreterPath;
|
||||
interpreterPath.resize(256);
|
||||
fd->Read(interpreterPath.data(), 256, Interp.p_offset);
|
||||
debug("Interpreter: %s", interpreterPath.c_str());
|
||||
|
||||
FileNode *ifd = fs->GetByPath((const char *)InterpreterPath.Get(), TargetProcess->Info.RootNode);
|
||||
FileNode *ifd = fs->GetByPath(interpreterPath.c_str(), TargetProcess->Info.RootNode);
|
||||
if (ifd == nullptr)
|
||||
{
|
||||
warn("Failed to open interpreter file: %s",
|
||||
(const char *)InterpreterPath.Get());
|
||||
warn("Failed to open interpreter file: %s", interpreterPath.c_str());
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetBinaryType((const char *)InterpreterPath.Get()) != BinTypeELF)
|
||||
if (GetBinaryType(interpreterPath) != BinTypeELF)
|
||||
{
|
||||
warn("Interpreter %s is not an ELF file",
|
||||
(const char *)InterpreterPath.Get());
|
||||
warn("Interpreter %s is not an ELF file", interpreterPath.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -322,23 +322,23 @@ namespace Execute
|
||||
std::vector<Elf64_Phdr> PhdrINTERP = ELFGetSymbolType_x86_64(fd, PT_INTERP);
|
||||
foreach (auto Interp in PhdrINTERP)
|
||||
{
|
||||
Memory::SmartHeap InterpreterPath = Memory::SmartHeap(256);
|
||||
fd->Read(InterpreterPath, 256, Interp.p_offset);
|
||||
InterpreterPath = InterpreterPath;
|
||||
std::string interpreterPath;
|
||||
interpreterPath.resize(256);
|
||||
fd->Read(interpreterPath.data(), 256, Interp.p_offset);
|
||||
debug("Interpreter: %s", (const char *)interpreterPath.c_str());
|
||||
|
||||
FileNode *ifd = fs->GetByPath((const char *)InterpreterPath.Get(), TargetProcess->Info.RootNode);
|
||||
FileNode *ifd = fs->GetByPath(interpreterPath.c_str(), TargetProcess->Info.RootNode);
|
||||
if (ifd == nullptr)
|
||||
{
|
||||
warn("Failed to open interpreter file: %s",
|
||||
(const char *)InterpreterPath.Get());
|
||||
warn("Failed to open interpreter file: %s", interpreterPath.c_str());
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GetBinaryType((const char *)InterpreterPath.Get()) != BinTypeELF)
|
||||
debug("ifd: %p, interpreter: %s", ifd, interpreterPath.c_str());
|
||||
if (GetBinaryType(interpreterPath) != BinTypeELF)
|
||||
{
|
||||
warn("Interpreter %s is not an ELF file",
|
||||
(const char *)InterpreterPath.Get());
|
||||
warn("Interpreter %s is not an ELF file", interpreterPath.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
This file is part of Fennix Kernel.
|
||||
|
||||
Fennix Kernel is free software: you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
Fennix Kernel is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __FENNIX_KERNEL_MEMORY_SMART_HEAP_H__
|
||||
#define __FENNIX_KERNEL_MEMORY_SMART_HEAP_H__
|
||||
|
||||
#include <types.h>
|
||||
#include <memory/vma.hpp>
|
||||
#include <convert.h>
|
||||
#include <cstddef>
|
||||
|
||||
namespace Memory
|
||||
{
|
||||
class SmartHeap
|
||||
{
|
||||
private:
|
||||
VirtualMemoryArea *vma = nullptr;
|
||||
void *Object = nullptr;
|
||||
std::size_t ObjectSize = 0;
|
||||
|
||||
public:
|
||||
auto Get() { return Object; }
|
||||
SmartHeap(std::size_t Size,
|
||||
VirtualMemoryArea *vma = nullptr);
|
||||
~SmartHeap();
|
||||
|
||||
void *operator->() { return Object; }
|
||||
void *operator*() { return Object; }
|
||||
operator void *() { return Object; }
|
||||
|
||||
operator const char *()
|
||||
{
|
||||
return r_cst(const char *, Object);
|
||||
}
|
||||
|
||||
operator uintptr_t()
|
||||
{
|
||||
return r_cst(uintptr_t, Object);
|
||||
}
|
||||
|
||||
operator uint8_t *()
|
||||
{
|
||||
return r_cst(uint8_t *, Object);
|
||||
}
|
||||
|
||||
void operator=(void *Address)
|
||||
{
|
||||
memcpy(Object, Address, ObjectSize);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // !__FENNIX_KERNEL_MEMORY_SMART_HEAP_H__
|
@ -22,6 +22,7 @@
|
||||
#include <list>
|
||||
|
||||
#include <memory/table.hpp>
|
||||
#include <memory/vma.hpp>
|
||||
|
||||
namespace Memory
|
||||
{
|
||||
|
@ -1758,8 +1758,8 @@ static int linux_uname(SysFrm *, struct utsname *buf)
|
||||
};
|
||||
rn->Stat(&st);
|
||||
|
||||
Memory::SmartHeap sh = Memory::SmartHeap(st.Size);
|
||||
rn->Read(sh.Get(), st.Size, 0);
|
||||
char *sh = new char[st.Size];
|
||||
rn->Read(sh, st.Size, 0);
|
||||
|
||||
ini_t *ini = ini_load(sh, NULL);
|
||||
int section = ini_find_section(ini, "uname", NULL);
|
||||
@ -1790,6 +1790,8 @@ static int linux_uname(SysFrm *, struct utsname *buf)
|
||||
if (uMac && strcmp(uMac, "auto") != 0)
|
||||
strncpy(uname.machine, uMac, sizeof(uname.machine));
|
||||
ini_destroy(ini);
|
||||
|
||||
delete[] sh;
|
||||
}
|
||||
else
|
||||
warn("Couldn't open /etc/cross/linux");
|
||||
|
Loading…
x
Reference in New Issue
Block a user