[libcxx-commits] [PATCH] D145789: [libc++][NFC] Use std::malloc and std::free instead of unqualified versions in tests

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 10 11:45:00 PST 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG14c5227c4120: [libc++][NFC] Use std::malloc and std::free instead of unqualified versions in… (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145789/new/

https://reviews.llvm.org/D145789

Files:
  libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared_for_overwrite.pass.cpp
  libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique_for_overwrite.default_init.pass.cpp


Index: libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique_for_overwrite.default_init.pass.cpp
===================================================================
--- libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique_for_overwrite.default_init.pass.cpp
+++ libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.create/make_unique_for_overwrite.default_init.pass.cpp
@@ -20,13 +20,13 @@
 #include <cassert>
 #include <concepts>
 #include <cstddef>
+#include <cstdlib>
 #include <memory>
-#include <stdlib.h>
 
 constexpr char pattern = 0xDE;
 
 void* operator new(std::size_t count) {
-  void* ptr = malloc(count);
+  void* ptr = std::malloc(count);
   for (std::size_t i = 0; i < count; ++i) {
     *(reinterpret_cast<char*>(ptr) + i) = pattern;
   }
@@ -35,7 +35,7 @@
 
 void* operator new[](std::size_t count) { return ::operator new(count); }
 
-void operator delete(void* ptr) noexcept { free(ptr); }
+void operator delete(void* ptr) noexcept { std::free(ptr); }
 
 void operator delete[](void* ptr) noexcept { ::operator delete(ptr); }
 
Index: libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared_for_overwrite.pass.cpp
===================================================================
--- libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared_for_overwrite.pass.cpp
+++ libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared_for_overwrite.pass.cpp
@@ -17,9 +17,9 @@
 
 #include <cassert>
 #include <concepts>
+#include <cstdlib>
 #include <cstring>
 #include <memory>
-#include <stdlib.h>
 #include <utility>
 
 #include "test_macros.h"
@@ -59,7 +59,7 @@
 constexpr char pattern = 0xDE;
 
 void* operator new(std::size_t count) {
-  void* ptr = malloc(count);
+  void* ptr = std::malloc(count);
   for (std::size_t i = 0; i < count; ++i) {
     *(reinterpret_cast<char*>(ptr) + i) = pattern;
   }
@@ -68,7 +68,7 @@
 
 void* operator new[](std::size_t count) { return ::operator new(count); }
 
-void operator delete(void* ptr) noexcept { free(ptr); }
+void operator delete(void* ptr) noexcept { std::free(ptr); }
 
 void operator delete[](void* ptr) noexcept { ::operator delete(ptr); }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145789.504235.patch
Type: text/x-patch
Size: 2313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230310/cd9dd18a/attachment-0001.bin>


More information about the libcxx-commits mailing list