• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef LIBPANDABASE_MEM_MALLOC_MEM_POOL_H
17 #define LIBPANDABASE_MEM_MALLOC_MEM_POOL_H
18 
19 #include "mem_pool.h"
20 
21 namespace panda {
22 
23 // Simple Mem Pool without cache
24 class MallocMemPool : public MemPool<MallocMemPool> {
25 private:
26     template <class ArenaT = Arena>
27     ArenaT *AllocArenaImpl(size_t size, SpaceType space_type, AllocatorType allocator_type, const void *allocator_addr);
28 
29     template <class ArenaT = Arena>
30     void FreeArenaImpl(ArenaT *arena);
31 
32     static Pool AllocPoolImpl(size_t size, SpaceType space_type, AllocatorType allocator_type,
33                               const void *allocator_addr);
34 
35     static void FreePoolImpl(void *mem, size_t size);
36 
37     static AllocatorInfo GetAllocatorInfoForAddrImpl(const void *addr);
38 
39     static SpaceType GetSpaceTypeForAddrImpl(const void *addr);
40 
41     static void *GetStartAddrPoolForAddrImpl(const void *addr);
42 
43     MallocMemPool();
44 
45     ~MallocMemPool() override = default;
46 
47     NO_COPY_SEMANTIC(MallocMemPool);
48     NO_MOVE_SEMANTIC(MallocMemPool);
49 
50     friend class PoolManager;
51     friend class MemPool<MallocMemPool>;
52 };
53 
54 }  // namespace panda
55 
56 #endif  // LIBPANDABASE_MEM_MALLOC_MEM_POOL_H
57