Fix reading Time zone rules using Julian days (#17672)
[platform/upstream/coreclr.git] / src / jit / hostallocator.cpp
1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
4
5 #include "jitpch.h"
6 #include "hostallocator.h"
7
8 HostAllocator HostAllocator::s_hostAllocator;
9
10 void* HostAllocator::Alloc(size_t size)
11 {
12     assert(g_jitHost != nullptr);
13     return g_jitHost->allocateMemory(size, false);
14 }
15
16 void* HostAllocator::ArrayAlloc(size_t elemSize, size_t numElems)
17 {
18     assert(g_jitHost != nullptr);
19
20     ClrSafeInt<size_t> safeElemSize(elemSize);
21     ClrSafeInt<size_t> safeNumElems(numElems);
22     ClrSafeInt<size_t> size = safeElemSize * safeNumElems;
23     if (size.IsOverflow())
24     {
25         return nullptr;
26     }
27
28     return g_jitHost->allocateMemory(size.Value(), false);
29 }
30
31 void HostAllocator::Free(void* p)
32 {
33     assert(g_jitHost != nullptr);
34     g_jitHost->freeMemory(p, false);
35 }
36
37 HostAllocator* HostAllocator::getHostAllocator()
38 {
39     return &s_hostAllocator;
40 }