Make the 2 versions of delete more similar

2013-10-02 Thread Marc Glisse

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.gli...@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 GlisseIndex: 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);
 }


Re: Make the 2 versions of delete more similar

2013-10-02 Thread Christopher Jefferson
On 2 October 2013 13:28, Marc Glisse marc.gli...@inria.fr wrote:
 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.gli...@inria.fr

 * libsupc++/del_op.cc (operator delete): Don't test for 0 before
 free.

Just checking, for the nervous:

Is the plan that this change will not effect any code behaviour (as
correct implementations of free are happy to take a NULL pointer, and
not do anything)?

Chris


  _GLIBCXX_WEAK_DEFINITION void
  operator delete(void* ptr) _GLIBCXX_USE_NOEXCEPT
  {
 -  if (ptr)
 -std::free(ptr);
 +  std::free(ptr);
  }


Re: Make the 2 versions of delete more similar

2013-10-02 Thread Jonathan Wakely
On 2 October 2013 13:28, Marc Glisse wrote:
 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.gli...@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::.

Looks good to me, thanks.