Migrated engine to using dlmalloc through eng::

This commit is contained in:
2022-02-24 02:17:41 -05:00
parent acc00289fb
commit f467944095
61 changed files with 631 additions and 590 deletions

View File

@@ -54,25 +54,38 @@ bool operator!=(EngAllocator<T> const&, EngAllocator<U> const&) noexcept
return false;
}
// namespace eng {
// DrvAllocator: a class meant to be used as an STL Allocator.
// Causes objects to be allocated using malloc and free.
template <class T>
class DrvAllocator
{
public:
using value_type = T;
DrvAllocator() noexcept {}
template <class U> DrvAllocator(DrvAllocator<U> const&) noexcept {}
// template<class T>
// using hash = std::hash<T>;
value_type* allocate(std::size_t n)
{
return static_cast<value_type*>(dlmalloc(n*sizeof(value_type)));
}
// template<class T>
// using less = std::less<T>;
void deallocate(value_type* p, std::size_t) noexcept
{
dlfree(p);
}
};
// template<class T>
// using equal_to = std::equal_to<T>;
template <class T, class U>
bool operator==(DrvAllocator<T> const&, DrvAllocator<U> const&) noexcept
{
return true;
}
// template<class T>
// using char_traits = std::char_traits<T>;
template <class T, class U>
bool operator!=(DrvAllocator<T> const&, DrvAllocator<U> const&) noexcept
{
return false;
}
// template<class A, class B>
// using pair = std::pair<A, B>;
// }
#endif // TWO_MALLOCS_HPP