Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

malloc_heap.hpp
Go to the documentation of this file.
1 //
2 // immer: immutable data structures for C++
3 // Copyright (C) 2016, 2017, 2018 Juan Pedro Bolivar Puente
4 //
5 // This software is distributed under the Boost Software License, Version 1.0.
6 // See accompanying file LICENSE or copy at http://boost.org/LICENSE_1_0.txt
7 //
8 
9 #pragma once
10 
11 #include <immer/config.hpp>
12 
13 #include <memory>
14 #include <cstdlib>
15 
16 namespace immer {
17 
22 {
27  template <typename... Tags>
28  static void* allocate(std::size_t size, Tags...)
29  {
30  auto p = std::malloc(size);
31  if (IMMER_UNLIKELY(!p))
32  throw std::bad_alloc{};
33  return p;
34  }
35 
41  static void deallocate(std::size_t, void* data)
42  {
43  std::free(data);
44  }
45 };
46 
47 } // namespace immer
#define IMMER_UNLIKELY(cond)
Definition: config.hpp:47
std::size_t size_t
Definition: bits.hpp:21
static void deallocate(std::size_t, void *data)
Definition: malloc_heap.hpp:41
static void * allocate(std::size_t size, Tags...)
Definition: malloc_heap.hpp:28
Released under the MIT license