[llvm] r216360 - Support/Path: remove raw delete

Dylan Noblesmith nobled at dreamwidth.org
Sun Aug 24 17:58:13 PDT 2014


Author: nobled
Date: Sun Aug 24 19:58:13 2014
New Revision: 216360

URL: http://llvm.org/viewvc/llvm-project?rev=216360&view=rev
Log:
Support/Path: remove raw delete

Modified:
    llvm/trunk/lib/Support/Path.cpp

Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=216360&r1=216359&r2=216360&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Sun Aug 24 19:58:13 2014
@@ -881,7 +881,8 @@ std::error_code copy_file(const Twine &F
   }
 
   const size_t BufSize = 4096;
-  char *Buf = new char[BufSize];
+  std::vector<char> Buffer(BufSize);
+  char *Buf = Buffer.data();
   int BytesRead = 0, BytesWritten = 0;
   for (;;) {
     BytesRead = read(ReadFD, Buf, BufSize);
@@ -898,7 +899,6 @@ std::error_code copy_file(const Twine &F
   }
   close(ReadFD);
   close(WriteFD);
-  delete[] Buf;
 
   if (BytesRead < 0 || BytesWritten < 0)
     return std::error_code(errno, std::generic_category());





More information about the llvm-commits mailing list