summaryrefslogtreecommitdiffhomepage
path: root/compat/process-list.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-12-26 12:45:00 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-12-26 12:56:24 +0100
commit8c20d01a1b6df262ed6c77aa44b49d3611e36a80 (patch)
tree47bf9a5bee34441695843a7eeaf1543c1d04cf65 /compat/process-list.hpp
parent1a40b793adbdd7c8718b9f383eadd1ab0bb02cf0 (diff)
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.
Diffstat (limited to 'compat/process-list.hpp')
-rw-r--r--compat/process-list.hpp8
1 files changed, 4 insertions, 4 deletions
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<typename = void>
static QStringList get_all_executable_names()
{
- QStringList ret;
+ QStringList ret; ret.reserve(2048);
std::vector<int> vec;
while (true)
@@ -138,13 +138,13 @@ static QStringList get_all_executable_names()
template<typename = void>
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<typename = void>
QStringList get_all_executable_names()
{
- QStringList ret;
+ QStringList ret; ret.reserve(2048);
proc_t** procs = readproctab(PROC_FILLCOM);
if (procs == nullptr)
{