From 8c20d01a1b6df262ed6c77aa44b49d3611e36a80 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 26 Dec 2024 12:45:00 +0100 Subject: compat/process-list: be easier on malloc(3) The real fix would be to use pr-eallocated buffers thus completely avoiding malloc. But it's difficult to test on all platforms and avoid introducing subtle bugs. --- compat/process-list.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'compat/process-list.hpp') diff --git a/compat/process-list.hpp b/compat/process-list.hpp index 34d65a75..39e12603 100644 --- a/compat/process-list.hpp +++ b/compat/process-list.hpp @@ -52,7 +52,7 @@ static QStringList get_all_executable_names() template static QStringList get_all_executable_names() { - QStringList ret; + QStringList ret; ret.reserve(2048); std::vector vec; while (true) @@ -138,13 +138,13 @@ static QStringList get_all_executable_names() template QStringList get_all_executable_names() { - QStringList ret; + QStringList ret; ret.reserve(2048); 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); + QString tmp; tmp.reserve(255); procps_pids_new(&info, items, 3); @@ -190,7 +190,7 @@ QStringList get_all_executable_names() template QStringList get_all_executable_names() { - QStringList ret; + QStringList ret; ret.reserve(2048); proc_t** procs = readproctab(PROC_FILLCOM); if (procs == nullptr) { -- cgit v1.2.3