Commit Graph

64 Commits

Author SHA1 Message Date
Hisham
0b70439316 Fix buffer reuse. 2016-02-13 02:18:28 -02:00
Hisham
b2c2b2bfb3 Merge branch 'reuse-comm' 2016-02-02 15:58:50 +01:00
Hisham
1cfcc42a8f Reuse comm object if possible, avoid useless repetitions of free+strdup. 2016-02-02 15:56:52 +01:00
Hisham
b54d2dde40 Check for failure in allocations. 2016-02-02 15:53:02 +01:00
Explorer09
6dae8108f8 Introduce CLAMP macro. Unify all MIN(MAX(a,b),c) uses.
With the CLAMP macro replacing the combination of MIN and MAX, we will
have at least two advantages:
1. It's more obvious semantically.
2. There are no more mixes of confusing uses like MIN(MAX(a,b),c) and
   MAX(MIN(a,b),c) and MIN(a,MAX(b,c)) appearing everywhere. We unify
   the 'clamping' with a single macro.
Note that the behavior of this CLAMP macro is different from
the combination `MAX(low,MIN(x,high))`.
* This CLAMP macro expands to two comparisons instead of three from
  MAX and MIN combination. In theory, this makes the code slightly
  smaller, in case that (low) or (high) or both are computed at
  runtime, so that compilers cannot optimize them. (The third
  comparison will matter if (low)>(high); see below.)
* CLAMP has a side effect, that if (low)>(high) it will produce weird
  results. Unlike MIN & MAX which will force either (low) or (high) to
  win. No assertion of ((low)<=(high)) is done in this macro, for now.

This CLAMP macro is implemented like described in glib
<http://developer.gnome.org/glib/stable/glib-Standard-Macros.html>
and does not handle weird uses like CLAMP(a++, low++, high--) .
2016-01-15 20:26:01 +08:00
Michael Klein
b10e54cdee Merge remote-tracking branch 'upstream/master' into envscreen 2016-01-06 22:39:57 +01:00
Hisham Muhammad
be9edc5d43 Merge branch 'master' of https://github.com/hishamhm/htop 2016-01-03 16:32:48 -02:00
Michael McConville
7170382706 Fix spelling of "maintainer" 2016-01-02 12:11:26 -05:00
Hisham Muhammad
802e216870 Extend buffer for reading lines from /proc.
Apparently a line longer than 255 chars was spotted in the wild:
http://serverfault.com/questions/577939/linux-ps-htop-show-processes-running-for-hundreds-or-thousands-of-days-though-h#comment676098_577939
2015-12-14 13:27:11 -02:00
Michael Klein
cc23d13f87 Add Platform_getProcessEnv
- currently implemented for darwin and linux
2015-12-03 22:23:40 +01:00
Hisham Muhammad
a84aa2e782 Cached memory calculations, take 2.
Thanks to @OmegaPhil for discussion and reviewing.
2015-11-29 23:55:31 -02:00
Hisham Muhammad
5bc1f5ed04 Account unreclaimable slab and shmem as used memory,
reclaimable slab as cached memory.

Hopefully this presents a more truthful representation of
available vs. used memory on Linux.
See brndnmtthws/conky#82, #242, #67, #263.
2015-11-28 22:22:00 -02:00
Hisham Muhammad
b669540e4e Merge pull request #298 from patrickmarlier/issue202
Fix a case where the usertime calculation can overflow (see issue #202)
2015-10-26 17:55:13 -04:00
Hisham Muhammad
71190654bc Calculate CPU averages on Darwin (See #295). 2015-10-23 13:46:21 -02:00
Martin "eto" Misuth
93f05b459f fixed broken merge, where I forgot to check linux/Platform.c so that it matches upstream 2015-10-06 20:05:55 +02:00
Martin "eto" Misuth
2379835910 Added platform dependent DEFAULT_SIGNAL define, for now for:
FreeBSD
Linux
Other platforms will have it undefined for now.
2015-10-06 14:04:22 +02:00
Hisham Muhammad
3fe2f3e28e Move list of signals to platform-specific code.
Implementations for Linux (tested) and FreeBSD (still untested, thanks to @etosan for providing the table).
Darwin and OpenBSD(ping @mmcco) builds should be broken now, pending their own tables.
2015-10-06 03:02:49 -03:00
Patrick Marlier
b37d4f172f Fix a case where the usertime calculation can overflow (see issue #202) 2015-09-14 22:51:14 +02:00
Christian Hesse
e8970b6f32 fix calloc() calls
* size_t nmemb (number of elements) first, then size_t size
* do not assume char is size 1 but use sizeof()
* allocate for char, not pointer to char (found by Michael McConville,
  fixes #261)
2015-09-07 07:52:39 +02:00
Hisham Muhammad
5e4f1e46cc Reduce scope of variables. 2015-08-20 01:12:34 -03:00
Hisham Muhammad
9428010121 Make column width calculation dynamic.
Closes #228.
2015-08-20 00:32:47 -03:00
David Hunt
5e602f18d5 Rename String to StringUtils.
Fixes building on case-insensitive filesystems where String.h gets confused with <string.h>.

From d734dacea0a10d0465dad4e95b3421511e7da112 Mon Sep 17 00:00:00 2001
From: David Hunt <dhunt@iolanthe.attlocal.net>
Date: Sat, 11 Jul 2015 20:56:31 -0500
Subject: [PATCH 1/8] Rename String to StringUtils
2015-08-19 13:45:20 -03:00
Hisham Muhammad
e42d78007e Merge pull request #230 from maksqwe/cstime_fix
Fix sort by cstime
2015-08-12 17:08:26 -03:00
peter-warhzner
6f6f0e36ad Fix typo in comment 2015-08-04 18:48:34 +05:00
Maks Naumov
1bdee6b6ba Fix sort by cstime 2015-07-23 14:24:39 +03:00
Christian Hesse
08829cbc3b fix compiler warnings
gcc gives warnings like this:

warning: ignoring return value of ‘fscanf’, declared with attribute
warn_unused_result

Assign value to a variable, cast to (void) to discard it.
2015-05-15 11:33:25 +02:00
Hisham Muhammad
f4f6d54ffd Fix compilation of OpenVZ support.
Closes #185.
Closes #190.
2015-05-13 15:00:58 -03:00
Hisham Muhammad
2f45008477 Enable OOM support unconditionally on Linux.
Read OOM data only if column is enabled.
Make sort ordering more consistent. Closes #182.
2015-04-09 15:41:21 -03:00
Hisham Muhammad
b291fba02b Fixes to use platform-specific compare routines. 2015-04-09 15:40:46 -03:00
Hisham Muhammad
d880def0e9 Merge branch 'master' into wip
Conflicts:
	Process.c
	Process.h
	htop.c
	linux/LinuxProcess.c
	linux/LinuxProcess.h
	test_spec.lua
2015-04-02 01:57:37 -03:00
Hisham Muhammad
4c24a9b462 Fixes to subclassing Process. 2015-03-31 23:23:10 -03:00
Hisham Muhammad
7cb8cb05fb Simplify constructors. 2015-03-23 19:24:34 -03:00
Hisham Muhammad
d0c72c3fb2 Move FunctionBar inside Panel 2015-03-23 15:26:56 -03:00
Hisham Muhammad
4e064e0db7 Build fixes to resync with FreeBSD changes. 2015-03-16 23:03:40 -03:00
Hisham Muhammad
272e2d9b34 Major advances in FreeBSD port. 2015-03-16 23:02:03 -03:00
Hisham Muhammad
7fd4af80ff Linux build fixes. 2015-03-16 03:25:43 -03:00
Hisham Muhammad
5c8b83405b Merge branch 'master' into wip
Conflicts:
	Process.c
	Process.h
	linux/LinuxProcess.c
	linux/LinuxProcess.h
	linux/LinuxProcessList.c
	unsupported/Platform.c
	unsupported/Platform.h
2015-03-16 03:22:33 -03:00
Hisham Muhammad
adbfe3c3f1 Get FreeBSD tree to compile again with latest changes. 2015-03-16 03:14:20 -03:00
Hisham Muhammad
be1700cf94 Isolate portable and Linux-specific process fields. 2015-03-16 01:43:04 -03:00
Hisham Muhammad
e3fe3962cb Move more Linux-specific code into Linux subdir. 2015-03-15 20:29:13 -03:00
Hisham Muhammad
e7d6eb6a82 Fix deletion of processes. Closes #172.
Conflicts:
	linux/LinuxProcess.c
2015-03-08 19:52:28 -03:00
Hisham Muhammad
a4b03e8875 Improve reading of cgroups. 2015-03-08 19:47:49 -03:00
Hisham Muhammad
39a725abc2 Fix deletion of processes. Closes #172. 2015-03-08 19:45:56 -03:00
Hisham Muhammad
0a184b769f Merge fixes 2015-02-23 03:53:36 -03:00
Hisham Muhammad
50000d808e Silence warnings reported in #70. 2015-02-23 03:34:06 -03:00
Hisham Muhammad
9780c312f4 Fix allocation of processes. Closes #166.
Conflicts:
	Process.c
	Process.h
	ProcessList.c
	ScreenManager.c
	linux/LinuxProcessList.c
2015-02-23 01:13:40 -03:00
Hisham Muhammad
6f868b00c0 Fix allocation of processes. Closes #166. 2015-02-20 14:52:10 -02:00
Hisham Muhammad
83a829a286 Remove bogus assertion. Closes #159. 2015-01-23 11:22:55 -02:00
Hisham Muhammad
c2108e5a48 Another mega-patch for the refactoring process.
Kinda runs, but functionality from the original main loop
is still missing. Patience.
2015-01-23 03:08:21 -02:00
Hisham Muhammad
3383d8e556 Sorry about the mega-patch.
This is a work-in-progress, code is currently broken.
(Some actions, and notably, the header, are missing.)
2015-01-21 23:27:31 -02:00