summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorнаб <nabijaczleweli@nabijaczleweli.xyz>2024-11-11 15:20:06 +0100
committerнаб <nabijaczleweli@nabijaczleweli.xyz>2024-11-11 15:52:43 +0100
commitd20575e93c38afb15fbc3e3bfc5e0e6a3903c299 (patch)
treee19e12bd61ba8767915604129831948184532f7b /apt-pkg
parente59793e29ecb47c63b72de4f9d1e6d044a0ff6f2 (diff)
Turn std::unique_ptr<char[]/std::array<char>>(APT_BUFFER_SIZE) buffers into std::array<char, APT_BUFFER_SIZE>
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);