mn_basic_malloc_allocator.hpp
Go to the documentation of this file.
1 /*
2 *This file is part of the Mini Thread Library (https://github.com/RoseLeBlood/MiniThread ).
3 *Copyright (c) 2018 Amber-Sophia Schroeck
4 *
5 *The Mini Thread Library is free software; you can redistribute it and/or modify
6 *it under the terms of the GNU Lesser General Public License as published by
7 *the Free Software Foundation, version 3, or (at your option) any later version.
8 
9 *The Mini Thread Library is distributed in the hope that it will be useful, but
10 *WITHOUT ANY WARRANTY; without even the implied warranty of
11 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 *General Public License for more details.
13 *
14 *You should have received a copy of the GNU Lesser General Public
15 *License along with the Mini Thread Library; if not, see
16 *<https://www.gnu.org/licenses/>.
17 */
18 #ifndef __MINILIB_MEM_BASIC_MALLOC_ALLOCATOR_H__
19 #define __MINILIB_MEM_BASIC_MALLOC_ALLOCATOR_H__
20 
21 #include "../mn_config.hpp"
22 
23 #include <cstdlib>
24 #include <memory>
25 
26 #include "mn_basic_allocator.hpp"
28 
29 namespace mn {
30  namespace memory {
31 
33  public:
36 
37  static void first() noexcept { }
38 
39  static void* allocate(size_t size, size_t alignment) noexcept {
40  MN_UNUSED_VARIABLE(alignment);
41  return malloc(size);
42  }
43 
44  static void deallocate(void* ptr, size_t size, size_t alignment) noexcept {
45  MN_UNUSED_VARIABLE(size);
46  MN_UNUSED_VARIABLE(alignment);
47  free(ptr);
48  }
49 
50  static size_t max_node_size() {
51  return size_t(-1);
52  }
53 
54  static size_t get_max_alocator_size() {
55  return __SIZE_MAX__;
56  }
57  };
58 
59  template <class TFilter = basic_allocator_filter>
61  }
62 }
63 
64 #endif // __MINILIB_MEM_BASIC_MALLOC_ALLOCATOR_H__
Definition: mn_basic_allocator.hpp:49
Definition: mn_basic_malloc_allocator.hpp:32
static void * allocate(size_t size, size_t alignment) noexcept
Definition: mn_basic_malloc_allocator.hpp:39
static void deallocate(void *ptr, size_t size, size_t alignment) noexcept
Definition: mn_basic_malloc_allocator.hpp:44
std_allocator_tag() allocator_category
Definition: mn_basic_malloc_allocator.hpp:34
static size_t get_max_alocator_size()
Definition: mn_basic_malloc_allocator.hpp:54
static size_t max_node_size()
Definition: mn_basic_malloc_allocator.hpp:50
std::false_type is_thread_safe
Definition: mn_basic_malloc_allocator.hpp:35
static void first() noexcept
Definition: mn_basic_malloc_allocator.hpp:37
#define MN_UNUSED_VARIABLE(var)
Definition: mn_defines.hpp:40
Definition: mn_allocator_typetraits.hpp:27
Definition: mn_allocator_typetraits.hpp:25
MN_THREAD_CONFIG_SIZE_TYPE size_t
Definition: mn_def.hpp:48
integral_constant< bool, false > false_type
Definition: mn_typetraits.hpp:130