1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00

Merge pull request #13577 from NixOS/mergify/bp/2.28-maintenance/pr-13175

libutil/tarfile: Create the scratch `std::vector` only once (backport #13175)
This commit is contained in:
mergify[bot] 2025-07-30 13:26:14 +00:00 committed by GitHub
commit 0d763f7ce2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -182,6 +182,10 @@ time_t unpackTarfileToSink(TarArchive & archive, ExtendedFileSystemObjectSink &
{
time_t lastModified = 0;
/* Only allocate the buffer once. Use the heap because 131 KiB is a bit too
much for the stack. */
std::vector<unsigned char> buf(128 * 1024);
for (;;) {
// FIXME: merge with extract_archive
struct archive_entry * entry;
@ -216,7 +220,6 @@ time_t unpackTarfileToSink(TarArchive & archive, ExtendedFileSystemObjectSink &
crf.isExecutable();
while (true) {
std::vector<unsigned char> buf(128 * 1024);
auto n = archive_read_data(archive.archive, buf.data(), buf.size());
if (n < 0)
throw Error("cannot read file '%s' from tarball", path);