diff options
author | rbuj <[email protected]> | 2020-12-16 21:28:46 +0100 |
---|---|---|
committer | Victor Kareh <[email protected]> | 2020-12-17 07:29:54 -0500 |
commit | c85a5cf5f08bee3706c0a450a971bfcdd2938a0d (patch) | |
tree | 9b9a238e4b0c4ee51bca59d0d6e41cf27170e68d /multiload/src/netspeed.c | |
parent | 99d50b247e1ec9714ff5922cea60a29d1a864ff0 (diff) | |
download | mate-applets-c85a5cf5f08bee3706c0a450a971bfcdd2938a0d.tar.bz2 mate-applets-c85a5cf5f08bee3706c0a450a971bfcdd2938a0d.tar.xz |
multiload: use guint64 as data source for graphs
Diffstat (limited to 'multiload/src/netspeed.c')
-rw-r--r-- | multiload/src/netspeed.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/multiload/src/netspeed.c b/multiload/src/netspeed.c index 3e889c8f..a61ce04b 100644 --- a/multiload/src/netspeed.c +++ b/multiload/src/netspeed.c @@ -1,6 +1,5 @@ #include <config.h> #include <glib.h> -#include <time.h> #include "netspeed.h" @@ -9,13 +8,14 @@ enum { N_STATES = 4 }; struct _NetSpeed { LoadGraph *graph; - gulong states[N_STATES]; + guint64 states[N_STATES]; size_t cur; }; -NetSpeed* netspeed_new(LoadGraph *g) +NetSpeed* +netspeed_new (LoadGraph *g) { - NetSpeed *ns = g_new0(NetSpeed, 1); + NetSpeed *ns = g_new0 (NetSpeed, 1); ns->graph = g; return ns; } @@ -25,31 +25,22 @@ void netspeed_delete(NetSpeed *ns) g_free(ns); } -void netspeed_add(NetSpeed *ns, gulong tx) +void +netspeed_add (NetSpeed *ns, + guint64 tx) { ns->cur = (ns->cur + 1) % N_STATES; ns->states[ns->cur] = tx; } -/* Something very similar to g_format_size() but for rates. - * This should give the same display as in g-s-m */ -static char* -format_rate_for_display(guint rate) +char* +netspeed_get (NetSpeed *ns) { - char *bytes; - char *text; - - bytes = g_format_size (rate); - text = g_strdup_printf (_("%s/s"), bytes); - g_free (bytes); - - return text; -} - -char* netspeed_get(NetSpeed *ns) -{ - gulong older, newer; - guint rate; + guint64 older; + guint64 newer; + guint64 rate; + char *bytes; + char *text; newer = ns->states[ns->cur]; older = ns->states[(ns->cur + 1) % N_STATES]; @@ -65,6 +56,9 @@ char* netspeed_get(NetSpeed *ns) few seconds. */ rate = 0; - return format_rate_for_display(rate); -} + bytes = g_format_size (rate); + text = g_strdup_printf (_("%s/s"), bytes); + g_free (bytes); + return text; +} |