2000-10-11 01:43:26 +02:00
|
|
|
// The -*- C++ -*- dynamic memory management header.
|
2001-02-07 21:26:24 +01:00
|
|
|
|
2016-01-04 15:30:50 +01:00
|
|
|
// Copyright (C) 1994-2016 Free Software Foundation, Inc.
|
2000-10-11 01:43:26 +02:00
|
|
|
|
Makefile.am, [...]: Replace "GNU CC" with "GCC".
2003-05-24 Nathanael Nerode <neroden@gcc.gnu.org>
* libsupc++/Makefile.am, libsupc++/cxxabi.h, libsupc++/del_op.cc,
libsupc++/del_opnt.cc, libsupc++/del_opv.cc, libsupc++/del_opvnt.cc,
libsupc++/eh_alloc.cc, libsupc++/eh_aux_runtime.cc,
libsupc++/eh_catch.cc, libsupc++/eh_exception.cc,
libsupc++/eh_globals.cc, libsupc++/eh_personality.cc,
libsupc++/eh_term_handler.cc, libsupc++/eh_terminate.cc,
libsupc++/eh_throw.cc, libsupc++/eh_type.cc,
libsupc++/eh_unex_handler.cc, libsupc++/exception,
libsupc++/new, libsupc++/new_handler.cc, libsupc++/new_op.cc,
libsupc++/new_opnt.cc, libsupc++/new_opv.cc, libsupc++/new_opvnt.cc,
libsupc++/pure.cc, libsupc++/tinfo.cc, libsupc++/tinfo2.cc,
libsupc++/typeinfo, libsupc++/unwind-cxx.h, libsupc++/vec.cc:
Replace "GNU CC" with "GCC".
From-SVN: r67155
2003-05-24 18:22:03 +02:00
|
|
|
// This file is part of GCC.
|
2000-10-11 01:43:26 +02:00
|
|
|
//
|
Makefile.am, [...]: Replace "GNU CC" with "GCC".
2003-05-24 Nathanael Nerode <neroden@gcc.gnu.org>
* libsupc++/Makefile.am, libsupc++/cxxabi.h, libsupc++/del_op.cc,
libsupc++/del_opnt.cc, libsupc++/del_opv.cc, libsupc++/del_opvnt.cc,
libsupc++/eh_alloc.cc, libsupc++/eh_aux_runtime.cc,
libsupc++/eh_catch.cc, libsupc++/eh_exception.cc,
libsupc++/eh_globals.cc, libsupc++/eh_personality.cc,
libsupc++/eh_term_handler.cc, libsupc++/eh_terminate.cc,
libsupc++/eh_throw.cc, libsupc++/eh_type.cc,
libsupc++/eh_unex_handler.cc, libsupc++/exception,
libsupc++/new, libsupc++/new_handler.cc, libsupc++/new_op.cc,
libsupc++/new_opnt.cc, libsupc++/new_opv.cc, libsupc++/new_opvnt.cc,
libsupc++/pure.cc, libsupc++/tinfo.cc, libsupc++/tinfo2.cc,
libsupc++/typeinfo, libsupc++/unwind-cxx.h, libsupc++/vec.cc:
Replace "GNU CC" with "GCC".
From-SVN: r67155
2003-05-24 18:22:03 +02:00
|
|
|
// GCC is free software; you can redistribute it and/or modify
|
2000-10-11 01:43:26 +02:00
|
|
|
// it under the terms of the GNU General Public License as published by
|
2009-04-09 17:00:19 +02:00
|
|
|
// the Free Software Foundation; either version 3, or (at your option)
|
2000-10-11 01:43:26 +02:00
|
|
|
// any later version.
|
|
|
|
//
|
Makefile.am, [...]: Replace "GNU CC" with "GCC".
2003-05-24 Nathanael Nerode <neroden@gcc.gnu.org>
* libsupc++/Makefile.am, libsupc++/cxxabi.h, libsupc++/del_op.cc,
libsupc++/del_opnt.cc, libsupc++/del_opv.cc, libsupc++/del_opvnt.cc,
libsupc++/eh_alloc.cc, libsupc++/eh_aux_runtime.cc,
libsupc++/eh_catch.cc, libsupc++/eh_exception.cc,
libsupc++/eh_globals.cc, libsupc++/eh_personality.cc,
libsupc++/eh_term_handler.cc, libsupc++/eh_terminate.cc,
libsupc++/eh_throw.cc, libsupc++/eh_type.cc,
libsupc++/eh_unex_handler.cc, libsupc++/exception,
libsupc++/new, libsupc++/new_handler.cc, libsupc++/new_op.cc,
libsupc++/new_opnt.cc, libsupc++/new_opv.cc, libsupc++/new_opvnt.cc,
libsupc++/pure.cc, libsupc++/tinfo.cc, libsupc++/tinfo2.cc,
libsupc++/typeinfo, libsupc++/unwind-cxx.h, libsupc++/vec.cc:
Replace "GNU CC" with "GCC".
From-SVN: r67155
2003-05-24 18:22:03 +02:00
|
|
|
// GCC is distributed in the hope that it will be useful,
|
2000-10-11 01:43:26 +02:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2000-10-11 01:43:26 +02:00
|
|
|
|
2001-07-11 21:35:49 +02:00
|
|
|
/** @file new
|
2006-11-29 21:59:22 +01:00
|
|
|
* This is a Standard C++ Library header.
|
|
|
|
*
|
Makefile.am (doxygen, [...]): Tweak targets.
2002-01-28 Phil Edwards <pme@gcc.gnu.org>
* Makefile.am (doxygen, doxygen-maint, doxygen-man): Tweak targets.
* Makefile.in: Regenerate.
* docs/doxygen/run_doxygen: Update, mostly for man pages.
* docs/doxygen/Intro.3: Update.
* docs/doxygen/TODO: Update.
* docs/doxygen/doxygroups.cc: Add namespace hook for __gnu_cxx.
* docs/doxygen/mainpage.doxy: Update.
* docs/doxygen/user.cfg.in: Update for header rename. Also
regenerate comments and variables with 1.2.12.
* docs/doxygen/maint.cfg.in: Remove file.
* include/bits/stl_relops.h: Doxygenate.
* include/bits/stl_tempbuf.h (std::_Temporary_buffer): Likewise.
* include/c_std/std_cassert.h, include/c_std/std_cctype.h,
include/c_std/std_cerrno.h, include/c_std/std_cfloat.h,
include/c_std/std_ciso646.h, include/c_std/std_climits.h,
include/c_std/std_clocale.h, include/c_std/std_cmath.h,
include/c_std/std_csetjmp.h, include/c_std/std_csignal.h,
include/c_std/std_cstdarg.h, include/c_std/std_cstddef.h,
include/c_std/std_cstdio.h, include/c_std/std_cstdlib.h,
include/c_std/std_cstring.h, include/c_std/std_ctime.h,
include/c_std/std_cwchar.h, include/c_std/std_cwctype.h,
include/ext/algorithm, include/ext/functional, include/ext/hash_map,
include/ext/hash_set, include/ext/iterator, include/ext/memory,
include/ext/numeric, include/ext/rb_tree, include/ext/rope,
include/ext/ropeimpl.h, include/ext/slist, include/ext/stl_hash_fun.h,
include/ext/stl_hashtable.h, include/ext/stl_rope.h,
include/std/std_algorithm.h, include/std/std_bitset.h,
include/std/std_complex.h, include/std/std_deque.h,
include/std/std_fstream.h, include/std/std_functional.h,
include/std/std_iomanip.h, include/std/std_ios.h,
include/std/std_iosfwd.h, include/std/std_iostream.h,
include/std/std_istream.h, include/std/std_iterator.h,
include/std/std_limits.h, include/std/std_list.h,
include/std/std_locale.h, include/std/std_map.h,
include/std/std_memory.h, include/std/std_numeric.h,
include/std/std_ostream.h, include/std/std_queue.h,
include/std/std_set.h, include/std/std_sstream.h,
include/std/std_stack.h, include/std/std_stdexcept.h,
include/std/std_streambuf.h, include/std/std_string.h,
include/std/std_utility.h, include/std/std_valarray.h,
include/std/std_vector.h: Add/correct @file doxygen hook.
* include/ext/memory: Doxygenate most of rest of file.
* libsupc++/exception: Doxygen output formatting.
* libsupc++/new: Say which header it is.
* testsuite/lib/libstdc++-v3-dg.exp: Fix spacing.
* docs/html/19_diagnostics/howto.html: Describe concept-checks switch.
* docs/html/23_containers/howto.html: Describe O(n) list::size().
* docs/html/27_io/howto.html: Also link to Langer and Kreft text.
From-SVN: r49300
2002-01-28 23:13:12 +01:00
|
|
|
* The header @c new defines several functions to manage dynamic memory and
|
2001-07-11 21:35:49 +02:00
|
|
|
* handling memory allocation errors; see
|
|
|
|
* http://gcc.gnu.org/onlinedocs/libstdc++/18_support/howto.html#4 for more.
|
|
|
|
*/
|
|
|
|
|
2003-07-05 06:05:45 +02:00
|
|
|
#ifndef _NEW
|
|
|
|
#define _NEW
|
2000-10-11 01:43:26 +02:00
|
|
|
|
2010-02-18 18:58:53 +01:00
|
|
|
#pragma GCC system_header
|
|
|
|
|
2010-06-03 21:15:56 +02:00
|
|
|
#include <bits/c++config.h>
|
2000-10-11 01:43:26 +02:00
|
|
|
#include <exception>
|
|
|
|
|
2004-08-03 08:45:54 +02:00
|
|
|
#pragma GCC visibility push(default)
|
|
|
|
|
2000-10-11 01:43:26 +02:00
|
|
|
extern "C++" {
|
|
|
|
|
2001-02-07 21:26:24 +01:00
|
|
|
namespace std
|
|
|
|
{
|
abi.txt: New file.
2002-07-20 Phil Edwards <pme@gcc.gnu.org>
* docs/html/abi.txt: New file.
* docs/html/23_containers/howto.html: Tweak vector-overhead text.
* docs/html/ext/lwg-active.html, docs/html/ext/lwg-defects.html:
Import from upstream, R22.
* include/bits/char_traits.h, include/bits/stl_iterator.h,
include/bits/stl_iterator_base_types.h, libsupc++/exception,
libsupc++/new, libsupc++/typeinfo: Use @brief markup.
* include/bits/deque.tcc, include/bits/stl_alloc.h,
include/bits/stl_deque.h, include/bits/stl_list.h: Postpone removal
of deprecated functions until 3.4. (Same timeframe, different text.)
* include/bits/stl_vector.h: Ditto. Also do the same cleanups that
the other sequence classes received.
From-SVN: r55602
2002-07-20 08:26:27 +02:00
|
|
|
/**
|
|
|
|
* @brief Exception possibly thrown by @c new.
|
2009-02-21 01:45:21 +01:00
|
|
|
* @ingroup exceptions
|
abi.txt: New file.
2002-07-20 Phil Edwards <pme@gcc.gnu.org>
* docs/html/abi.txt: New file.
* docs/html/23_containers/howto.html: Tweak vector-overhead text.
* docs/html/ext/lwg-active.html, docs/html/ext/lwg-defects.html:
Import from upstream, R22.
* include/bits/char_traits.h, include/bits/stl_iterator.h,
include/bits/stl_iterator_base_types.h, libsupc++/exception,
libsupc++/new, libsupc++/typeinfo: Use @brief markup.
* include/bits/deque.tcc, include/bits/stl_alloc.h,
include/bits/stl_deque.h, include/bits/stl_list.h: Postpone removal
of deprecated functions until 3.4. (Same timeframe, different text.)
* include/bits/stl_vector.h: Ditto. Also do the same cleanups that
the other sequence classes received.
From-SVN: r55602
2002-07-20 08:26:27 +02:00
|
|
|
*
|
|
|
|
* @c bad_alloc (or classes derived from it) is used to report allocation
|
2001-07-11 21:35:49 +02:00
|
|
|
* errors from the throwing forms of @c new. */
|
2001-02-07 21:26:24 +01:00
|
|
|
class bad_alloc : public exception
|
|
|
|
{
|
2000-10-11 01:43:26 +02:00
|
|
|
public:
|
2001-03-13 20:32:00 +01:00
|
|
|
bad_alloc() throw() { }
|
2007-06-26 13:01:15 +02:00
|
|
|
|
2002-01-10 00:31:57 +01:00
|
|
|
// This declaration is not useless:
|
|
|
|
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
|
2002-01-09 21:39:27 +01:00
|
|
|
virtual ~bad_alloc() throw();
|
2007-06-26 13:01:15 +02:00
|
|
|
|
2007-02-01 14:36:51 +01:00
|
|
|
// See comment in eh_exception.cc.
|
|
|
|
virtual const char* what() const throw();
|
2000-10-11 01:43:26 +02:00
|
|
|
};
|
|
|
|
|
2013-05-09 05:58:00 +02:00
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
class bad_array_new_length : public bad_alloc
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
bad_array_new_length() throw() { };
|
|
|
|
|
|
|
|
// This declaration is not useless:
|
|
|
|
// http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
|
|
|
|
virtual ~bad_array_new_length() throw();
|
|
|
|
|
|
|
|
// See comment in eh_exception.cc.
|
|
|
|
virtual const char* what() const throw();
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2016-09-09 23:22:15 +02:00
|
|
|
#if __cpp_aligned_new
|
|
|
|
enum class align_val_t: size_t {};
|
|
|
|
#endif
|
|
|
|
|
2015-11-11 15:47:19 +01:00
|
|
|
struct nothrow_t
|
|
|
|
{
|
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
explicit nothrow_t() = default;
|
|
|
|
#endif
|
|
|
|
};
|
2007-06-26 13:01:15 +02:00
|
|
|
|
2000-10-11 01:43:26 +02:00
|
|
|
extern const nothrow_t nothrow;
|
2007-06-26 13:01:15 +02:00
|
|
|
|
2001-07-11 21:35:49 +02:00
|
|
|
/** If you write your own error handler to be called by @c new, it must
|
|
|
|
* be of this type. */
|
2000-10-11 01:43:26 +02:00
|
|
|
typedef void (*new_handler)();
|
2007-06-26 13:01:15 +02:00
|
|
|
|
|
|
|
/// Takes a replacement handler as the argument, returns the
|
|
|
|
/// previous handler.
|
2002-07-16 10:28:40 +02:00
|
|
|
new_handler set_new_handler(new_handler) throw();
|
2013-04-03 02:08:54 +02:00
|
|
|
|
|
|
|
#if __cplusplus >= 201103L
|
|
|
|
/// Return the current new handler.
|
|
|
|
new_handler get_new_handler() noexcept;
|
|
|
|
#endif
|
2000-10-11 01:43:26 +02:00
|
|
|
} // namespace std
|
|
|
|
|
2001-07-11 21:35:49 +02:00
|
|
|
//@{
|
|
|
|
/** These are replaceable signatures:
|
|
|
|
* - normal single new and delete (no arguments, throw @c bad_alloc on error)
|
|
|
|
* - normal array new and delete (same)
|
|
|
|
* - @c nothrow single new and delete (take a @c nothrow argument, return
|
|
|
|
* @c NULL on error)
|
|
|
|
* - @c nothrow array new and delete (same)
|
|
|
|
*
|
|
|
|
* Placement new and delete signatures (take a memory address argument,
|
|
|
|
* does nothing) may not be replaced by a user's program.
|
|
|
|
*/
|
2011-10-12 20:40:58 +02:00
|
|
|
void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
|
|
|
|
__attribute__((__externally_visible__));
|
|
|
|
void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
|
|
|
|
__attribute__((__externally_visible__));
|
|
|
|
void operator delete(void*) _GLIBCXX_USE_NOEXCEPT
|
|
|
|
__attribute__((__externally_visible__));
|
|
|
|
void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT
|
|
|
|
__attribute__((__externally_visible__));
|
2015-11-03 17:43:54 +01:00
|
|
|
#if __cpp_sized_deallocation
|
|
|
|
void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
|
|
|
|
__attribute__((__externally_visible__));
|
|
|
|
void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
|
|
|
|
__attribute__((__externally_visible__));
|
|
|
|
#endif
|
2011-10-12 20:40:58 +02:00
|
|
|
void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
|
|
|
|
__attribute__((__externally_visible__));
|
|
|
|
void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
|
|
|
|
__attribute__((__externally_visible__));
|
|
|
|
void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
|
|
|
|
__attribute__((__externally_visible__));
|
|
|
|
void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
|
|
|
|
__attribute__((__externally_visible__));
|
2016-09-09 23:22:15 +02:00
|
|
|
#if __cpp_aligned_new
|
|
|
|
void* operator new(std::size_t, std::align_val_t)
|
|
|
|
__attribute__((__externally_visible__));
|
|
|
|
void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
|
|
|
|
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
|
|
|
|
void operator delete(void*, std::align_val_t)
|
|
|
|
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
|
|
|
|
void operator delete(void*, std::align_val_t, const std::nothrow_t&)
|
|
|
|
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
|
|
|
|
void* operator new[](std::size_t, std::align_val_t)
|
|
|
|
__attribute__((__externally_visible__));
|
|
|
|
void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
|
|
|
|
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
|
|
|
|
void operator delete[](void*, std::align_val_t)
|
|
|
|
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
|
|
|
|
void operator delete[](void*, std::align_val_t, const std::nothrow_t&)
|
|
|
|
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
|
|
|
|
#if __cpp_sized_deallocation
|
|
|
|
void operator delete(void*, std::size_t, std::align_val_t)
|
|
|
|
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
|
|
|
|
void operator delete[](void*, std::size_t, std::align_val_t)
|
|
|
|
_GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
|
|
|
|
#endif // __cpp_sized_deallocation
|
|
|
|
#endif // __cpp_aligned_new
|
2000-10-11 01:43:26 +02:00
|
|
|
|
2001-02-07 21:26:24 +01:00
|
|
|
// Default placement versions of operator new.
|
2011-10-12 20:40:58 +02:00
|
|
|
inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
|
|
|
|
{ return __p; }
|
|
|
|
inline void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
|
|
|
|
{ return __p; }
|
2002-07-24 21:49:21 +02:00
|
|
|
|
|
|
|
// Default placement versions of operator delete.
|
2011-10-12 20:40:58 +02:00
|
|
|
inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { }
|
|
|
|
inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { }
|
2001-07-11 21:35:49 +02:00
|
|
|
//@}
|
2000-10-11 01:43:26 +02:00
|
|
|
} // extern "C++"
|
|
|
|
|
2004-08-03 08:45:54 +02:00
|
|
|
#pragma GCC visibility pop
|
|
|
|
|
2000-10-11 01:43:26 +02:00
|
|
|
#endif
|