aboutsummaryrefslogtreecommitdiff
path: root/source/Host
diff options
context:
space:
mode:
authorDavid Carlier <devnexen@gmail.com>2019-09-09 16:10:14 +0000
committerDavid Carlier <devnexen@gmail.com>2019-09-09 16:10:14 +0000
commit0073edfa1cd97c0e84975dc00dfee64f0516e8f8 (patch)
treed2afc8cefeb75c28c664639769fb94ea0a96ce10 /source/Host
parent99d2a3485de3849e6508b64937864fffe39c606c (diff)
downloadlldb-0073edfa1cd97c0e84975dc00dfee64f0516e8f8.tar.gz
LLDB - Simplify GetProgramFileSpec
Reviewers: zturner, emaste Reviewed By: emaste Differential Revision: https://reviews.llvm.org/D46518 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@371417 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source/Host')
-rw-r--r--source/Host/freebsd/HostInfoFreeBSD.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/source/Host/freebsd/HostInfoFreeBSD.cpp b/source/Host/freebsd/HostInfoFreeBSD.cpp
index e28cf4aa4..eeaf22276 100644
--- a/source/Host/freebsd/HostInfoFreeBSD.cpp
+++ b/source/Host/freebsd/HostInfoFreeBSD.cpp
@@ -64,13 +64,10 @@ FileSpec HostInfoFreeBSD::GetProgramFileSpec() {
static FileSpec g_program_filespec;
if (!g_program_filespec) {
int exe_path_mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, getpid()};
- size_t exe_path_size;
- if (sysctl(exe_path_mib, 4, NULL, &exe_path_size, NULL, 0) == 0) {
- char *exe_path = new char[exe_path_size];
- if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0)
- g_program_filespec.SetFile(exe_path, FileSpec::Style::native);
- delete[] exe_path;
- }
+ char exe_path[PATH_MAX];
+ size_t exe_path_size = sizeof(exe_path);
+ if (sysctl(exe_path_mib, 4, exe_path, &exe_path_size, NULL, 0) == 0)
+ g_program_filespec.SetFile(exe_path, false);
}
return g_program_filespec;
}