summaryrefslogtreecommitdiff
path: root/service/uptr.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2018-03-06 21:37:39 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2018-03-06 21:37:39 +0000
commitba25f019012b632f6af9f5addee5058ba6a4e077 (patch)
treef9e5bc70a9fb075e43f11ca4a02493147e4b3d50 /service/uptr.cpp
parentAdd basic site setup (diff)
downloadmirrorsearch-ba25f019012b632f6af9f5addee5058ba6a4e077.tar.bz2
mirrorsearch-ba25f019012b632f6af9f5addee5058ba6a4e077.tar.xz
mirrorsearch-ba25f019012b632f6af9f5addee5058ba6a4e077.zip
Wrap support for making unique ptrs from functions
Diffstat (limited to 'service/uptr.cpp')
-rw-r--r--service/uptr.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/service/uptr.cpp b/service/uptr.cpp
new file mode 100644
index 0000000..1669a69
--- /dev/null
+++ b/service/uptr.cpp
@@ -0,0 +1,26 @@
+#include "uptr.h"
+#include <execinfo.h>
+#include <boost/assert.hpp>
+#include <string>
+#include <stdlib.h>
+#include <exception>
+
+namespace MirrorSearch {
+
+ std::string
+ failingFunction(void * const func)
+ {
+ char ** fn = backtrace_symbols(&func, 1);
+ BOOST_ASSERT(fn);
+ BOOST_ASSERT(*fn);
+ std::string funcName(*fn);
+ free(fn);
+ return funcName;
+ }
+
+ void
+ defaultErrorHandler(const std::string & fn)
+ {
+ throw std::runtime_error("Fatal error in " + fn);
+ }
+}