YAMI4 Core
allocator.h
1 // Copyright Maciej Sobczak 2008-2019.
2 // This file is part of YAMI4.
3 //
4 // YAMI4 is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // YAMI4 is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with YAMI4. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef YAMICORE_ALLOCATOR_H_INCLUDED
18 #define YAMICORE_ALLOCATOR_H_INCLUDED
19 
20 #include "dll.h"
21 
22 #include <cstddef>
23 
24 namespace yami
25 {
26 
27 namespace details
28 {
29 
30 class DLL allocator
31 {
32 public:
33  allocator();
34 
35  void set_working_area(void * buf, std::size_t size);
36 
37  void * allocate(std::size_t requested_size);
38 
39  void deallocate(const void * p);
40 
41  void get_free_size(std::size_t & biggest, std::size_t & all) const;
42 
43 private:
44  allocator(const allocator &);
45  void operator=(const allocator &);
46 
47  void * base_;
48  std::size_t size_;
49 
50  void * first_free_segment_;
51 };
52 
53 } // namespace details
54 
55 } // namespace yami
56 
57 #endif // YAMICORE_ALLOCATOR_H_INCLUDED
Namespace devoted for everything related to YAMI4.
Definition: agent.h:25