]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/libsupc++/del_opnt.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / libsupc++ / del_opnt.cc
index 75051d5bee10f23f1951f63b799059d4f710dc60..c33246e1629f38903d5bc602ebdd122746584fdd 100644 (file)
@@ -1,6 +1,6 @@
 // Boilerplate support routines for -*- C++ -*- dynamic memory management.
 
-// Copyright (C) 1997, 1998, 1999, 2000, 2004, 2009 Free Software Foundation
+// Copyright (C) 1997-2021 Free Software Foundation, Inc.
 //
 // This file is part of GCC.
 //
 // <http://www.gnu.org/licenses/>.
 
 #include <bits/c++config.h>
-#include "new"
 
-extern "C" void free (void *);
+#if !_GLIBCXX_HOSTED
+// A freestanding C runtime may not provide "free" -- but there is no
+// other reasonable way to implement "operator delete".
+namespace std
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+  extern "C" void free(void*);
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace
+#else
+# include <cstdlib>
+#endif
+
+#include "new"
 
 _GLIBCXX_WEAK_DEFINITION void
-operator delete (void *ptr, const std::nothrow_t&) throw ()
+operator delete (void *ptr, const std::nothrow_t&) noexcept
 {
-  if (ptr)
-    free (ptr);
+  // _GLIBCXX_RESOLVE_LIB_DEFECTS
+  // 206. operator new(size_t, nothrow) may become unlinked to ordinary
+  // operator new if ordinary version replaced
+  ::operator delete (ptr);
 }