L4Re - L4 Runtime Environment
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>
24 namespace cxx {
30 class Nothrow {};
31 }
32 
39 inline void *operator new (size_t, void *mem, cxx::Nothrow const &) throw()
40 { return mem; }
41 
46 void *operator new (size_t, cxx::Nothrow const &) throw();
47 
48 namespace cxx {
49 
50 
59 template< typename _Type >
61 {
62 public:
63  enum { can_free = true };
64 
65  New_allocator() throw() {}
66  New_allocator(New_allocator const &) throw() {}
67 
68  ~New_allocator() throw() {}
69 
70  _Type *alloc() throw()
71  { return static_cast<_Type*>(::operator new(sizeof (_Type), cxx::Nothrow())); }
72 
73  void free(_Type *t) throw()
74  { ::operator delete(t); }
75 };
76 
77 }
78 
Our C++ library.
Definition: arith:22
Helper type to distinguish the oeprator new version that does not throw exceptions.
Definition: std_alloc:30
Standard allocator based on operator new () .
Definition: std_alloc:60