diff options
author | Bernat Arlandis <berarma@hotmail.com> | 2023-07-06 10:23:06 +0200 |
---|---|---|
committer | Bernat Arlandis <berarma@hotmail.com> | 2023-07-06 10:23:06 +0200 |
commit | 8e5a7763626998500566ca248f7c1670f084197d (patch) | |
tree | b79559bb83fdaf777bd2ddafa1c11732fc25dec9 | |
parent | 1e60eb97b75b1f9d204a8ed19da36a95f788fb7d (diff) |
Fixed styling and mallocs
-rw-r--r-- | compat/process-list.hpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/compat/process-list.hpp b/compat/process-list.hpp index 434766cb..26a5ceda 100644 --- a/compat/process-list.hpp +++ b/compat/process-list.hpp @@ -139,24 +139,31 @@ QStringList get_all_executable_names() { QStringList ret; enum pids_item items[] = { PIDS_ID_PID, PIDS_CMD, PIDS_CMDLINE_V }; + enum rel_items { rel_pid, rel_cmd, rel_cmdline }; struct pids_info *info = NULL; struct pids_stack *stack; + QString tmp; tmp.reserve(64); procps_pids_new(&info, items, 3); - while ((stack = procps_pids_get(info, PIDS_FETCH_TASKS_ONLY))) { + while ((stack = procps_pids_get(info, PIDS_FETCH_TASKS_ONLY))) + { char **p_cmdline = PIDS_VAL(rel_cmdline, strv, stack, info); // note, wine sets argv[0] so no parsing like in OSX case - if (p_cmdline && p_cmdline[0]) + if (p_cmdline && p_cmdline[0] && p_cmdline[0][0] && + !(p_cmdline[0][0] == '-' && !p_cmdline[0][1])) { - QString tmp(p_cmdline[0]); + tmp = QString{p_cmdline[0]}; const int idx = std::max(tmp.lastIndexOf('\\'), tmp.lastIndexOf('/')); - tmp = tmp.mid(idx == -1 ? 0 : idx+1); + if (idx != -1) + tmp = tmp.mid(idx+1); + //qDebug() << "procps" << tmp; ret.append(tmp); } } + //qDebug() << "-- procps end"; procps_pids_unref(&info); |