diff options
author | David Robillard <d@drobilla.net> | 2011-01-08 19:11:13 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-01-08 19:11:13 +0000 |
commit | 9a1cd7003886f89e2228d74d61130dc5d24c06a3 (patch) | |
tree | 133972adfb7802750f62d9db69639cd2c18459ba /src/binary_location.h | |
parent | c92301fc4cd5620fe8193e2e6648ea86c580784d (diff) | |
download | patchage-9a1cd7003886f89e2228d74d61130dc5d24c06a3.tar.gz patchage-9a1cd7003886f89e2228d74d61130dc5d24c06a3.tar.bz2 patchage-9a1cd7003886f89e2228d74d61130dc5d24c06a3.zip |
Support via waf for running from the build directory.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2799 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/binary_location.h')
-rw-r--r-- | src/binary_location.h | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/binary_location.h b/src/binary_location.h index 58868a7..033dcae 100644 --- a/src/binary_location.h +++ b/src/binary_location.h @@ -1,5 +1,5 @@ /* Find the location of the program in the filesytem. - * Copyright (C) 2008-2009 David Robillard <http://drobilla.net> + * Copyright (C) 2008-2010 David Robillard <http://drobilla.net> * * This is free software; you can redistribute it and/or modify it under the * terms of the GNU General Public License as published by the Free Software @@ -19,10 +19,10 @@ #define _GNU_SOURCE #endif -#include <dlfcn.h> -#include <stdio.h> -#include <stdlib.h> +#include <assert.h> #include <limits.h> +#include <stdlib.h> +#include <dlfcn.h> /** Return the absolute path of the binary. * Returned value must be freed by caller. @@ -31,11 +31,11 @@ static char* binary_location() { Dl_info dli; - dladdr((void*)&binary_location, &dli); - - char* bin_loc = (char*)calloc(PATH_MAX, sizeof(char)); - realpath(dli.dli_fname, bin_loc); - - return bin_loc; + const int ret = dladdr((void*)&binary_location, &dli); + if (ret) { + char* const bin_loc = (char*)calloc(PATH_MAX, sizeof(char)); + realpath(dli.dli_fname, bin_loc); + return bin_loc; + } + return NULL; } - |