]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/fileutl.cc
Deprecate SPtrArray<T> and convert everyone to unique_ptr<T[]>
[apt.git] / apt-pkg / contrib / fileutl.cc
index 4cc8112af9fb99366e28c45914b845b0a395483b..a6af27b0092f8a19a3d5c9f1f4206faf84b315ef 100644 (file)
@@ -52,6 +52,7 @@
 
 #include <set>
 #include <algorithm>
+#include <memory>
 
 #ifdef HAVE_ZLIB
        #include <zlib.h>
@@ -159,7 +160,7 @@ bool CopyFile(FileFd &From,FileFd &To)
       return false;
    
    // Buffered copy between fds
-   SPtrArray<unsigned char> Buf = new unsigned char[64000];
+   std::unique_ptr<unsigned char[]> Buf(new unsigned char[64000]);
    unsigned long long Size = From.Size();
    while (Size != 0)
    {
@@ -167,8 +168,8 @@ bool CopyFile(FileFd &From,FileFd &To)
       if (Size > 64000)
         ToRead = 64000;
       
-      if (From.Read(Buf,ToRead) == false || 
-         To.Write(Buf,ToRead) == false)
+      if (From.Read(Buf.get(),ToRead) == false ||
+         To.Write(Buf.get(),ToRead) == false)
         return false;
       
       Size -= ToRead;