*
* Copyright (c) 2005 Adi Zaimi, Dan Piponi <dan@tanelorn.demon.co.uk>,
* Dave Clark <clarkd@skynet.ca>
- * Copyright (c) 2005-2007 Brenden Matthews, Philip Kovacs, et. al.
+ * Copyright (c) 2005-2008 Brenden Matthews, Philip Kovacs, et. al.
* (see AUTHORS)
* All rights reserved.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * $Id$ */
+ */
#include "top.h"
* Anyone hoping to port wmtop should look here first. */
static int process_parse_stat(struct process *process)
{
- struct information *cur;
-
- cur = &info;
+ struct information *cur = &info;
char line[BUFFER_LEN] = { 0 }, filename[BUFFER_LEN], procname[BUFFER_LEN];
int ps;
unsigned long user_time = 0;
if (process->name) {
free(process->name);
}
- process->name = strdup(deparenthesised_name);
+ process->name = strndup(deparenthesised_name, text_buffer_size);
process->rss *= getpagesize();
if (!cur->memmax) {
int ps;
char line[BUFFER_LEN] = { 0 };
unsigned long long cpu = 0;
- unsigned long long nice = 0;
- unsigned long long system = 0;
+ unsigned long long niceval = 0;
+ unsigned long long systemval = 0;
unsigned long long idle = 0;
unsigned long long iowait = 0;
unsigned long long irq = 0;
unsigned long long softirq = 0;
unsigned long long steal = 0;
- char *template =
+ const char *template =
KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGPROC : TMPL_SHORTPROC;
ps = open("/proc/stat", O_RDONLY);
return 0;
}
- sscanf(line, template, &cpu, &nice, &system, &idle, &iowait, &irq,
+ sscanf(line, template, &cpu, &niceval, &systemval, &idle, &iowait, &irq,
&softirq, &steal);
- total = cpu + nice + system + idle + iowait + irq + softirq + steal;
+ total = cpu + niceval + systemval + idle + iowait + irq + softirq + steal;
t = total - previous_total;
previous_total = total;
* Results are stored in the cpu,mem arrays in decreasing order[0-9]. *
* ****************************************************************** */
-inline void process_find_top(struct process **cpu, struct process **mem)
+void process_find_top(struct process **cpu, struct process **mem)
{
struct sorted_process *spc_head = NULL, *spc_tail = NULL, *spc_cur = NULL;
struct sorted_process *spm_head = NULL, *spm_tail = NULL, *spm_cur = NULL;