@@ -78,11 +78,17 @@ runtime::Result<std::unique_ptr<runtime::DataLoader>> make_data_loader(
7878Module::Module (
7979 const std::string& file_path,
8080 const LoadMode load_mode,
81+ std::unique_ptr<runtime::MemoryAllocator> memory_allocator,
82+ std::unique_ptr<runtime::MemoryAllocator> temp_allocator,
8183 std::unique_ptr<runtime::EventTracer> event_tracer)
8284 : file_path_(file_path),
8385 load_mode_ (load_mode),
84- memory_allocator_(std::make_unique<MallocMemoryAllocator>()),
85- temp_allocator_(std::make_unique<MallocMemoryAllocator>()),
86+ memory_allocator_(
87+ memory_allocator ? std::move(memory_allocator)
88+ : std::make_unique<MallocMemoryAllocator>()),
89+ temp_allocator_(
90+ temp_allocator ? std::move(temp_allocator)
91+ : std::make_unique<MallocMemoryAllocator>()),
8692 event_tracer_(std::move(event_tracer)) {
8793 runtime::runtime_init ();
8894}
@@ -91,11 +97,17 @@ Module::Module(
9197 const std::string& file_path,
9298 const std::string& data_map_path,
9399 const LoadMode load_mode,
100+ std::unique_ptr<runtime::MemoryAllocator> memory_allocator,
101+ std::unique_ptr<runtime::MemoryAllocator> temp_allocator,
94102 std::unique_ptr<runtime::EventTracer> event_tracer)
95103 : file_path_(file_path),
96104 load_mode_(load_mode),
97- memory_allocator_(std::make_unique<MallocMemoryAllocator>()),
98- temp_allocator_(std::make_unique<MallocMemoryAllocator>()),
105+ memory_allocator_(
106+ memory_allocator ? std::move(memory_allocator)
107+ : std::make_unique<MallocMemoryAllocator>()),
108+ temp_allocator_(
109+ temp_allocator ? std::move(temp_allocator)
110+ : std::make_unique<MallocMemoryAllocator>()),
99111 event_tracer_(std::move(event_tracer)) {
100112 if (!data_map_path.empty ()) {
101113 data_files_.push_back (data_map_path);
@@ -107,12 +119,18 @@ Module::Module(
107119 const std::string& file_path,
108120 std::vector<std::string> data_files,
109121 const LoadMode load_mode,
122+ std::unique_ptr<runtime::MemoryAllocator> memory_allocator,
123+ std::unique_ptr<runtime::MemoryAllocator> temp_allocator,
110124 std::unique_ptr<runtime::EventTracer> event_tracer)
111125 : file_path_(file_path),
112126 data_files_(std::move(data_files)),
113127 load_mode_(load_mode),
114- memory_allocator_(std::make_unique<MallocMemoryAllocator>()),
115- temp_allocator_(std::make_unique<MallocMemoryAllocator>()),
128+ memory_allocator_(
129+ memory_allocator ? std::move(memory_allocator)
130+ : std::make_unique<MallocMemoryAllocator>()),
131+ temp_allocator_(
132+ temp_allocator ? std::move(temp_allocator)
133+ : std::make_unique<MallocMemoryAllocator>()),
116134 event_tracer_(std::move(event_tracer)) {
117135 runtime::runtime_init ();
118136}
0 commit comments