Line data Source code
1 : // SPDX-License-Identifier: Apache-2.0
2 : /**
3 : * Copyright (C) 2025 Jijoong Moon <jijoong.moon@samsung.com>
4 : *
5 : * @file mem_allocator.cpp
6 : * @date 13 Jan 2025
7 : * @see https://github.com/nnstreamer/nntrainer
8 : * @author Jijoong Moon <jijoong.moon@samsung.com>
9 : * @bug No known bugs except for NYI items
10 : * @brief This is memory allocator for memory pool
11 : *
12 : */
13 :
14 : #include <cstdlib>
15 : #include <limits>
16 : #include <mem_allocator.h>
17 : #include <nntrainer_log.h>
18 : #include <numeric>
19 : #include <vector>
20 :
21 : namespace nntrainer {
22 :
23 0 : void MemAllocator::alloc(void **ptr, size_t size, size_t alignment) {
24 0 : if (size == 0)
25 0 : ml_loge("cannot allocate size = 0");
26 :
27 0 : *ptr = std::calloc(size, 1);
28 0 : };
29 :
30 0 : void MemAllocator::free(void *ptr) { std::free(ptr); };
31 : } // namespace nntrainer
|