summaryrefslogtreecommitdiffstats
path: root/src/binary_location.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-01-09 20:05:06 +0000
committerDavid Robillard <d@drobilla.net>2015-01-09 20:05:06 +0000
commit4067bd81444736ddd7047210e2afdaaf9eaeaf40 (patch)
tree5cd70895cc5f4247996c321e044dfec7d063e9c7 /src/binary_location.h
parent1dff3fea90f2dc43a8bfc782eb88512344c1b5ae (diff)
downloadpatchage-4067bd81444736ddd7047210e2afdaaf9eaeaf40.tar.gz
patchage-4067bd81444736ddd7047210e2afdaaf9eaeaf40.tar.bz2
patchage-4067bd81444736ddd7047210e2afdaaf9eaeaf40.zip
Fix OSX integration.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5504 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/binary_location.h')
-rw-r--r--src/binary_location.h19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/binary_location.h b/src/binary_location.h
index 995f17f..91e8b29 100644
--- a/src/binary_location.h
+++ b/src/binary_location.h
@@ -23,20 +23,21 @@
#include <stdlib.h>
#include <dlfcn.h>
-/** Return the absolute path of the binary.
- * Returned value must be freed by caller.
- */
-static char*
+#include <string>
+
+/** Return the absolute path of the binary. */
+static std::string
binary_location()
{
- Dl_info dli;
+ 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)) {
- return NULL;
+ if (realpath(dli.dli_fname, bin_loc)) {
+ loc = bin_loc;
}
- return bin_loc;
+ free(bin_loc);
}
- return NULL;
+ return loc;
}