1 // Copyright 2024 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 // https://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, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14
15 #include "pw_allocator/allocator_as_pool.h"
16
17 namespace pw::allocator {
18
AllocatorAsPool(Allocator & allocator,const Layout & layout)19 AllocatorAsPool::AllocatorAsPool(Allocator& allocator, const Layout& layout)
20 : Pool(allocator.capabilities(), layout), allocator_(allocator) {}
21
DoAllocate()22 void* AllocatorAsPool::DoAllocate() { return allocator_.Allocate(layout()); }
23
DoDeallocate(void * ptr)24 void AllocatorAsPool::DoDeallocate(void* ptr) { allocator_.Deallocate(ptr); }
25
DoGetInfo(InfoType info_type,const void * ptr) const26 Result<Layout> AllocatorAsPool::DoGetInfo(InfoType info_type,
27 const void* ptr) const {
28 return GetInfo(allocator_, info_type, ptr);
29 }
30
31 } // namespace pw::allocator
32