L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
std_alloc
1// vi:set ft=cpp: -*- Mode: C++ -*-
2/*
3 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
4 * Alexander Warg <warg@os.inf.tu-dresden.de>
5 * economic rights: Technische Universität Dresden (Germany)
6 *
7 * This file is part of TUD:OS and distributed under the terms of the
8 * GNU General Public License 2.
9 * Please see the COPYING-GPL-2 file for details.
10 *
11 * As a special exception, you may use this file as part of a free software
12 * library without restriction. Specifically, if other files instantiate
13 * templates or use macros or inline functions from this file, or you compile
14 * this file and link it with other files to produce an executable, this
15 * file does not by itself cause the resulting executable to be covered by
16 * the GNU General Public License. This exception does not however
17 * invalidate any other reasons why the executable file might be covered by
18 * the GNU General Public License.
19 */
20
21#pragma once
22
23#include <stddef.h>
24namespace cxx {
30class Nothrow {};
31}
32
39inline void *operator new (size_t, void *mem, cxx::Nothrow const &) noexcept
40{ return mem; }
41
46void *operator new (size_t, cxx::Nothrow const &) noexcept;
47
53void operator delete (void *, cxx::Nothrow const &) noexcept;
54
55namespace cxx {
56
57
66template< typename _Type >
68{
69public:
70 enum { can_free = true };
71
72 New_allocator() noexcept {}
73 New_allocator(New_allocator const &) noexcept {}
74
75 ~New_allocator() noexcept {}
76
77 _Type *alloc() noexcept
78 { return static_cast<_Type*>(::operator new(sizeof (_Type), cxx::Nothrow())); }
79
80 void free(_Type *t) noexcept
81 { ::operator delete(t, cxx::Nothrow()); }
82};
83
84}
85
Standard allocator based on operator new () .
Definition std_alloc:68
Helper type to distinguish the oeprator new version that does not throw exceptions.
Definition std_alloc:30
Our C++ library.
Definition arith:22