summaryrefslogtreecommitdiff
path: root/nix/libutil/hash.cc
diff options
context:
space:
mode:
authorCongcong Kuo <congcong.kuo@gmail.com>2025-07-06 22:51:34 +0800
committerLudovic Courtès <ludo@gnu.org>2025-07-16 23:50:38 +0200
commitbd963ec99d5232df789b20e19b47900b1e27d7e3 (patch)
treee5709ff39eea8d68405389db62f0d9fa48f31595 /nix/libutil/hash.cc
parent02a94e80243b1ed1f84fc3cce2554f2d06fd1664 (diff)
daemon: Use std::string or std::vector instead of variable-length array (VLA).
* libutil/util.h (waitForMessage): Use std::string instead of char* to unify coding style. * libutil/util.cc (waitForMessage): Use std::string instead of variable-length array (VLA). (readLink, copyFileRecursively, expect): Use std::vector instead of VLA. * libutil/hash.cc (printHash): Use std::vector instead of VLA. Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'nix/libutil/hash.cc')
-rw-r--r--nix/libutil/hash.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/nix/libutil/hash.cc b/nix/libutil/hash.cc
index 9b83ffcdd9..3cb4d05318 100644
--- a/nix/libutil/hash.cc
+++ b/nix/libutil/hash.cc
@@ -64,12 +64,12 @@ const string base16Chars = "0123456789abcdef";
string printHash(const Hash & hash)
{
- char buf[hash.hashSize * 2];
+ std::vector<char> buf(hash.hashSize * 2);
for (unsigned int i = 0; i < hash.hashSize; i++) {
buf[i * 2] = base16Chars[hash.hash[i] >> 4];
buf[i * 2 + 1] = base16Chars[hash.hash[i] & 0x0f];
}
- return string(buf, hash.hashSize * 2);
+ return string(buf.begin(), buf.end());
}