summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/extracttar.cc10
-rw-r--r--apt-pkg/contrib/fileutl.cc7
2 files changed, 8 insertions, 9 deletions
diff --git a/apt-pkg/contrib/extracttar.cc b/apt-pkg/contrib/extracttar.cc
index dff9326a1..7b545de17 100644
--- a/apt-pkg/contrib/extracttar.cc
+++ b/apt-pkg/contrib/extracttar.cc
@@ -132,7 +132,7 @@ bool ExtractTar::Go(pkgDirStream &Stream)
// Loop over all blocks
string LastLongLink, ItemLink;
string LastLongName, ItemName;
- auto Junk = std::make_unique<std::array<unsigned char, 32*1024>>();
+ std::array<unsigned char, APT_BUFFER_SIZE> Junk;
while (1)
{
bool BadRecord = false;
@@ -295,19 +295,19 @@ bool ExtractTar::Go(pkgDirStream &Stream)
auto Size = Itm.Size;
do
{
- auto const Read = std::min<unsigned long long>(Size, Junk->size());
- if (not InFd.Read(Junk->data(), ((Read + (sizeof(Block) - 1)) / sizeof(Block)) * sizeof(Block)))
+ auto const Read = std::min<unsigned long long>(Size, Junk.size());
+ if (not InFd.Read(Junk.data(), ((Read + (sizeof(Block) - 1)) / sizeof(Block)) * sizeof(Block)))
return false;
if (Fd > 0)
{
- if (not FileFd::Write(Fd, Junk->data(), Read))
+ if (not FileFd::Write(Fd, Junk.data(), Read))
return Stream.Fail(Itm, Fd);
}
// An Fd of -2 means to send to a special processing function
else if (Fd == -2)
{
- if (not Stream.Process(Itm, Junk->data(), Read, Itm.Size - Size))
+ if (not Stream.Process(Itm, Junk.data(), Read, Itm.Size - Size))
return Stream.Fail(Itm, Fd);
}
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index db97738e3..957d068de 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -176,12 +176,11 @@ bool CopyFile(FileFd &From,FileFd &To)
return false;
// Buffered copy between fds
- constexpr size_t BufSize = APT_BUFFER_SIZE;
- std::unique_ptr<unsigned char[]> Buf(new unsigned char[BufSize]);
+ std::array<unsigned char, APT_BUFFER_SIZE> Buf;
unsigned long long ToRead = 0;
do {
- if (From.Read(Buf.get(),BufSize, &ToRead) == false ||
- To.Write(Buf.get(),ToRead) == false)
+ if (From.Read(Buf.data(),Buf.size(), &ToRead) == false ||
+ To.Write(Buf.data(),ToRead) == false)
return false;
} while (ToRead != 0);