#pragma once
#include <luna/Result.h>

namespace std
{
    struct nothrow_t
    {
        explicit nothrow_t() = default;
    };

    extern const nothrow_t nothrow;

    enum class align_val_t : usize
    {
    };
};

void* operator new(usize size, const std::nothrow_t&) noexcept;
void* operator new[](usize size, const std::nothrow_t&) noexcept;
void operator delete(void* ptr, usize size, std::align_val_t alignment) noexcept;

extern Result<void*> allocate_pages_impl(usize count);
extern Result<void> release_pages_impl(void* address, usize count);

Result<void*> malloc_impl(usize size, bool may_realloc = true, bool should_scrub = true);
Result<void*> calloc_impl(usize nmemb, usize size, bool may_realloc = true);
Result<void*> realloc_impl(void* ptr, usize size, bool may_realloc_again = true);
Result<void> free_impl(void* ptr);

void dump_heap_usage();