kernel+libluna: Avoid scrubbing when the memory is going to be overwritten anyway

This is the case for objects with constructors and temporary memory which is filled afterwards.
This commit is contained in:
apio 2023-08-27 20:48:33 +02:00
parent d48142f163
commit 6f3ed70363
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,7 @@ Result<u64> sys_poll(Registers*, SyscallArgs args)
nfds_t nfds = (nfds_t)args[1]; nfds_t nfds = (nfds_t)args[1];
int timeout = (int)args[2]; int timeout = (int)args[2];
struct pollfd* kfds = (struct pollfd*)TRY(malloc_impl(nfds * sizeof(pollfd))); struct pollfd* kfds = (struct pollfd*)TRY(malloc_impl(nfds * sizeof(pollfd), false, false));
auto guard = make_scope_guard([kfds] { free_impl(kfds); }); auto guard = make_scope_guard([kfds] { free_impl(kfds); });
if (!MemoryManager::copy_from_user(fds, kfds, nfds * sizeof(pollfd))) return err(EFAULT); if (!MemoryManager::copy_from_user(fds, kfds, nfds * sizeof(pollfd))) return err(EFAULT);

View File

@ -24,7 +24,7 @@
*/ */
template <typename T, class... Args> [[nodiscard]] Result<T*> make(Args... args) template <typename T, class... Args> [[nodiscard]] Result<T*> make(Args... args)
{ {
T* const result = (T*)TRY(malloc_impl(sizeof(T))); T* const result = (T*)TRY(malloc_impl(sizeof(T), false, false));
new (result) T(args...); new (result) T(args...);
return result; return result;
} }

View File

@ -425,12 +425,12 @@ void dump_heap_usage()
#ifdef USE_FREESTANDING #ifdef USE_FREESTANDING
void* operator new(usize size, const std::nothrow_t&) noexcept void* operator new(usize size, const std::nothrow_t&) noexcept
{ {
return malloc_impl(size).value_or(nullptr); return malloc_impl(size, false, false).value_or(nullptr);
} }
void* operator new[](usize size, const std::nothrow_t&) noexcept void* operator new[](usize size, const std::nothrow_t&) noexcept
{ {
return malloc_impl(size).value_or(nullptr); return malloc_impl(size, false, false).value_or(nullptr);
} }
void operator delete(void* p) noexcept void operator delete(void* p) noexcept