summaryrefslogtreecommitdiffstats
path: root/src/binary_location.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/binary_location.h')
-rw-r--r--src/binary_location.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/binary_location.h b/src/binary_location.h
index 111a04f..3705d94 100644
--- a/src/binary_location.h
+++ b/src/binary_location.h
@@ -26,24 +26,23 @@
#include <string>
/** Return the absolute path of the binary. */
-static std::string
+inline std::string
binary_location()
{
Dl_info dli;
std::string loc;
const int ret = dladdr((void*)&binary_location, &dli);
if (ret) {
- char* const bin_loc = (char*)calloc(PATH_MAX, 1);
- if (realpath(dli.dli_fname, bin_loc)) {
+ if (char* const bin_loc = realpath(dli.dli_fname, nullptr)) {
loc = bin_loc;
+ free(bin_loc);
}
- free(bin_loc);
}
return loc;
}
/** Return the absolute path of the bundle (binary parent directory). */
-static std::string
+inline std::string
bundle_location()
{
const std::string binary = binary_location();