summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/gpgv.cc
diff options
context:
space:
mode:
authorнаб <nabijaczleweli@nabijaczleweli.xyz>2024-11-12 13:28:04 +0100
committerнаб <nabijaczleweli@nabijaczleweli.xyz>2024-11-12 13:46:06 +0100
commit78e503bc1d79bc4fc29bc9cbe1dfb68ae4d16acf (patch)
tree67beaeec79a01ea97785bc5ad1476f3c2315e107 /apt-pkg/contrib/gpgv.cc
parentc87f3bdd1790bb75447c2ec8f95e5e07bdce58d5 (diff)
Turn unique_ptr<decltype(fclose and free)> into real deleter types (warnings now, UB in C++20)
Diffstat (limited to 'apt-pkg/contrib/gpgv.cc')
-rw-r--r--apt-pkg/contrib/gpgv.cc21
1 files changed, 12 insertions, 9 deletions
diff --git a/apt-pkg/contrib/gpgv.cc b/apt-pkg/contrib/gpgv.cc
index 225acae88..9ab3e066e 100644
--- a/apt-pkg/contrib/gpgv.cc
+++ b/apt-pkg/contrib/gpgv.cc
@@ -28,14 +28,17 @@
#include <apti18n.h>
/*}}}*/
-// syntactic sugar to wrap a raw pointer with a custom deleter in a std::unique_ptr
-static std::unique_ptr<char, decltype(&free)> make_unique_char(void *const str = nullptr)
-{
- return {static_cast<char *>(str), &free};
+namespace {
+ struct FILEDeleter {
+ void operator()(FILE *p) {
+ fclose(p);
+ }
+ };
}
-static std::unique_ptr<FILE, decltype(&fclose)> make_unique_FILE(std::string const &filename, char const *const mode)
+
+static std::unique_ptr<FILE, FILEDeleter> make_unique_FILE(std::string const &filename, char const *const mode)
{
- return {fopen(filename.c_str(), mode), &fclose};
+ return {fopen(filename.c_str(), mode), {}};
}
class LineBuffer /*{{{*/
@@ -207,9 +210,9 @@ void ExecGPGV(std::string const &File, std::string const &FileGPG,
}
enum { DETACHED, CLEARSIGNED } releaseSignature = (FileGPG != File) ? DETACHED : CLEARSIGNED;
- auto sig = make_unique_char();
- auto data = make_unique_char();
- auto conf = make_unique_char();
+ std::unique_ptr<char, FreeDeleter> sig;
+ std::unique_ptr<char, FreeDeleter> data;
+ std::unique_ptr<char, FreeDeleter> conf;
// Dump the configuration so apt-key picks up the correct Dir values
{