This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Make the 2 versions of delete more similar


Hello,

I don't understand why those 2 files differ by more than 1 extra argument, so I am changing that.

Bootstrap and testsuite on x86_64.

2013-10-03  Marc Glisse  <marc.glisse@inria.fr>

	* libsupc++/del_op.cc (operator delete): Don't test for 0 before free.
	* libsupc++/del_opnt.cc (free): Only declare if freestanding.
	(operator delete): Qualify free with std::.

--
Marc Glisse
Index: libsupc++/del_op.cc
===================================================================
--- libsupc++/del_op.cc	(revision 203101)
+++ libsupc++/del_op.cc	(working copy)
@@ -36,13 +36,12 @@ _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 #else
 # include <cstdlib>
 #endif
 
 #include "new"
 
 _GLIBCXX_WEAK_DEFINITION void
 operator delete(void* ptr) _GLIBCXX_USE_NOEXCEPT
 {
-  if (ptr)
-    std::free(ptr);
+  std::free(ptr);
 }
Index: libsupc++/del_opnt.cc
===================================================================
--- libsupc++/del_opnt.cc	(revision 203101)
+++ libsupc++/del_opnt.cc	(working copy)
@@ -17,19 +17,31 @@
 // 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/>.
 
 #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&) _GLIBCXX_USE_NOEXCEPT
 {
-  free (ptr);
+  std::free(ptr);
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]