74 lines
2.0 KiB
Diff
74 lines
2.0 KiB
Diff
Index: src/procman.h
|
|
===================================================================
|
|
--- src/procman.h (revision 2544)
|
|
+++ src/procman.h (working copy)
|
|
@@ -96,12 +96,10 @@
|
|
struct MutableProcInfo
|
|
{
|
|
MutableProcInfo()
|
|
- : user(0),
|
|
- status(0)
|
|
+ : status(0)
|
|
{ }
|
|
|
|
- // shared, don't free it !
|
|
- const gchar* user;
|
|
+ std::string user;
|
|
|
|
gchar wchan[40];
|
|
|
|
@@ -132,7 +130,7 @@
|
|
/* undefined */ ProcInfo& operator=(const ProcInfo&);
|
|
/* undefined */ ProcInfo(const ProcInfo&);
|
|
|
|
- typedef std::map<guint, const char*> UserMap;
|
|
+ typedef std::map<guint, std::string> UserMap;
|
|
/* cached username */
|
|
static UserMap users;
|
|
|
|
Index: src/proctable.cpp
|
|
===================================================================
|
|
--- src/proctable.cpp (revision 2544)
|
|
+++ src/proctable.cpp (working copy)
|
|
@@ -24,6 +24,7 @@
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include <glib/gi18n.h>
|
|
+#include <glib/gprintf.h>
|
|
#include <glibtop.h>
|
|
#include <glibtop/loadavg.h>
|
|
#include <glibtop/proclist.h>
|
|
@@ -465,16 +466,16 @@
|
|
// procman_debug("User lookup for uid %u: %s", uid, (p.second ? "MISS" : "HIT"));
|
|
|
|
if (p.second) {
|
|
- char* username;
|
|
struct passwd* pwd;
|
|
pwd = getpwuid(uid);
|
|
|
|
if (pwd && pwd->pw_name)
|
|
- username = g_strdup(pwd->pw_name);
|
|
- else
|
|
- username = g_strdup_printf("%u", uid);
|
|
-
|
|
- p.first->second = username;
|
|
+ p.first->second = pwd->pw_name;
|
|
+ else {
|
|
+ char username[16];
|
|
+ g_sprintf(username, "%u", uid);
|
|
+ p.first->second = username;
|
|
+ }
|
|
}
|
|
|
|
this->user = p.first->second;
|
|
@@ -543,7 +544,7 @@
|
|
using procman::tree_store_update;
|
|
|
|
tree_store_update(model, &info->node, COL_STATUS, info->status);
|
|
- tree_store_update(model, &info->node, COL_USER, info->user);
|
|
+ tree_store_update(model, &info->node, COL_USER, info->user.c_str());
|
|
tree_store_update(model, &info->node, COL_VMSIZE, info->vmsize);
|
|
tree_store_update(model, &info->node, COL_MEMRES, info->memres);
|
|
tree_store_update(model, &info->node, COL_MEMWRITABLE, info->memwritable);
|
|
|