8#include <aws/core/Core_EXPORTS.h>
10#include <aws/core/SDKConfig.h>
11#include <aws/core/utils/memory/AWSMemory.h>
12#include <aws/core/utils/memory/MemorySystemInterface.h>
13#include <aws/crt/StlAllocator.h>
20#ifdef USE_AWS_MEMORY_MANAGEMENT
29 template<
typename T >
using CrtAllocator = Aws::Crt::StlAllocator<T>;
36 class Allocator :
public std::allocator<T>
40 typedef std::allocator<T> Base;
46 Allocator(
const Allocator<T>& a)
throw() :
51 Allocator(
const Allocator<U>& a)
throw() :
55 ~Allocator() throw() {}
57 typedef std::size_t size_type;
62 typedef Allocator<U> other;
65 using RawPointer =
typename std::allocator_traits<std::allocator<T>>::pointer;
67 RawPointer allocate(size_type n,
const void *hint =
nullptr)
69 AWS_UNREFERENCED_PARAM(hint);
71 return reinterpret_cast<RawPointer
>(
Malloc(
"AWSSTL", n *
sizeof(T)));
74 void deallocate(RawPointer p, size_type n)
76 AWS_UNREFERENCED_PARAM(n);
84#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
85 template<
typename T >
86 bool operator ==(
const Allocator< T >& lhs,
const Allocator< T >& rhs)
88 AWS_UNREFERENCED_PARAM(lhs);
89 AWS_UNREFERENCED_PARAM(rhs);
98 template<
typename T >
using Allocator = std::allocator<T>;
105 template<typename T, typename ...ArgTypes>
106 std::shared_ptr<T>
MakeShared(
const char* allocationTag, ArgTypes&&... args)
108#ifdef USE_AWS_MEMORY_MANAGEMENT
112 AWS_ASSERT(memorySystem &&
"Memory system is not initialized.");
113 AWS_UNREFERENCED_PARAM(memorySystem);
115 AWS_UNREFERENCED_PARAM(allocationTag);
117 return std::allocate_shared<T, Aws::Allocator<T>>(
Aws::Allocator<T>(), std::forward<ArgTypes>(args)...);
AWS_CORE_API MemorySystemInterface * GetMemorySystem()
std::shared_ptr< T > MakeShared(const char *allocationTag, ArgTypes &&... args)
std::allocator< T > Allocator
AWS_CORE_API void * Malloc(const char *allocationTag, size_t allocationSize)
AWS_CORE_API void Free(void *memoryPtr)