ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
MemoryManagerCPU.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #include <Logging.h>
9 
10 #include <cstdlib>
11 
13 
14 namespace cloudViewer {
15 namespace core {
16 
17 void* MemoryManagerCPU::Malloc(size_t byte_size, const Device& device) {
18  void* ptr;
19  ptr = std::malloc(byte_size);
20  if (byte_size != 0 && !ptr) {
21  utility::LogError("CPU malloc failed");
22  }
23  return ptr;
24 }
25 
26 void MemoryManagerCPU::Free(void* ptr, const Device& device) {
27  if (ptr) {
28  std::free(ptr);
29  }
30 }
31 
32 void MemoryManagerCPU::Memcpy(void* dst_ptr,
33  const Device& dst_device,
34  const void* src_ptr,
35  const Device& src_device,
36  size_t num_bytes) {
37  std::memcpy(dst_ptr, src_ptr, num_bytes);
38 }
39 
40 } // namespace core
41 } // namespace cloudViewer
void Memcpy(void *dst_ptr, const Device &dst_device, const void *src_ptr, const Device &src_device, size_t num_bytes) override
void * Malloc(size_t byte_size, const Device &device) override
void Free(void *ptr, const Device &device) override
Frees previously allocated memory at address ptr on device device.
#define LogError(...)
Definition: Logging.h:60
Generic file read and write utility for python interface.