// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-class HostAllocator : public IAllocator
+#pragma once
+
+class HostAllocator final : public IAllocator
{
private:
static HostAllocator s_hostAllocator;
static HostAllocator* getHostAllocator();
};
+
+// Global operator new overloads that work with HostAllocator
+
+inline void* __cdecl operator new(size_t n, HostAllocator* alloc)
+{
+ return alloc->Alloc(n);
+}
+
+inline void* __cdecl operator new[](size_t n, HostAllocator* alloc)
+{
+ return alloc->Alloc(n);
+}
class Histogram
{
public:
- Histogram(IAllocator* allocator, const unsigned* const sizeTable);
+ Histogram(HostAllocator* allocator, const unsigned* const sizeTable);
~Histogram();
void dump(FILE* output);
private:
void ensureAllocated();
- IAllocator* m_allocator;
+ HostAllocator* m_allocator;
unsigned m_sizeCount;
const unsigned* const m_sizeTable;
unsigned* m_counts;
* Histogram class.
*/
-Histogram::Histogram(IAllocator* allocator, const unsigned* const sizeTable)
+Histogram::Histogram(HostAllocator* allocator, const unsigned* const sizeTable)
: m_allocator(allocator), m_sizeTable(sizeTable), m_counts(nullptr)
{
unsigned sizeCount = 0;
// MyAssembly;mscorlib;System
// MyAssembly;mscorlib System
-AssemblyNamesList2::AssemblyNamesList2(const wchar_t* list, IAllocator* alloc) : m_alloc(alloc)
+AssemblyNamesList2::AssemblyNamesList2(const wchar_t* list, HostAllocator* alloc) : m_alloc(alloc)
{
assert(m_alloc != nullptr);
#define _UTILS_H_
#include "iallocator.h"
+#include "hostallocator.h"
#include "cycletimer.h"
// Needed for unreached()
AssemblyName* m_next;
};
- AssemblyName* m_pNames; // List of names
- IAllocator* m_alloc; // IAllocator to use in this class
+ AssemblyName* m_pNames; // List of names
+ HostAllocator* m_alloc; // HostAllocator to use in this class
public:
// Take a Unicode string list of assembly names, parse it, and store it.
- AssemblyNamesList2(const wchar_t* list, __in IAllocator* alloc);
+ AssemblyNamesList2(const wchar_t* list, __in HostAllocator* alloc);
~AssemblyNamesList2();