#pragma once

#include <Juliet.h>
#include <Core/Common/CoreUtils.h>

#include <cstdlib>

namespace Juliet
{
    // Uninitialized allocation
    JULIET_API void* Malloc(size_t elem_size);
    // Initialized to 0 allocation
    JULIET_API void* Calloc(size_t nb_elem, size_t elem_size);
    JULIET_API void* Realloc(void* memory, size_t newSize);

    // Free
    template <typename Type>
    void Free(Type* memory)
    {
        Assert(memory);
        ::free(memory);
    }
    // Free and Set the ptr to nullptr
    template <typename Type>
    void SafeFree(Type*& memory)
    {
        if (memory)
        {
            ::free(memory);
            memory = nullptr;
        }
    }
} // namespace Juliet
