[Lldb-commits] [lldb] r371417 - LLDB - Simplify GetProgramFileSpec
David Carlier via lldb-commits
lldb-commits at lists.llvm.org
Mon Sep 9 09:10:14 PDT 2019
Author: devnexen
Date: Mon Sep 9 09:10:14 2019
New Revision: 371417
URL: http://llvm.org/viewvc/llvm-project?rev=371417&view=rev
Log:
LLDB - Simplify GetProgramFileSpec
Reviewers: zturner, emaste
Reviewed By: emaste
Differential Revision: https://reviews.llvm.org/D46518
Modified:
lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp
Modified: lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp?rev=371417&r1=371416&r2=371417&view=diff
==============================================================================
--- lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp (original)
+++ lldb/trunk/source/Host/freebsd/HostInfoFreeBSD.cpp Mon Sep 9 09:10:14 2019
@@ -64,13 +64,10 @@ FileSpec HostInfoFreeBSD::GetProgramFile
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;
}
More information about the lldb-commits
mailing list