From 871c4b2d024bef51df05f614c4e7759715c75dff Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 26 Nov 2009 01:10:19 +0100 Subject: [PATCH] convert buffers and cached to callbacks.print --- src/common.c | 12 ++++++++++++ src/common.h | 3 +++ src/conky.c | 6 ------ src/core.c | 2 ++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/common.c b/src/common.c index 3a1a5715..5b6e90cc 100644 --- a/src/common.c +++ b/src/common.c @@ -589,3 +589,15 @@ void print_threads(struct text_object *obj, char *p, int p_max_size) (void)obj; spaced_print(p, p_max_size, "%hu", 4, info.threads); } + +void print_buffers(struct text_object *obj, char *p, int p_max_size) +{ + (void)obj; + human_readable(info.buffers * 1024, p, p_max_size); +} + +void print_cached(struct text_object *obj, char *p, int p_max_size) +{ + (void)obj; + human_readable(info.cached * 1024, p, p_max_size); +} diff --git a/src/common.h b/src/common.h index 1693a61b..779332b2 100644 --- a/src/common.h +++ b/src/common.h @@ -99,4 +99,7 @@ void print_running_processes(struct text_object *, char *, int); void print_running_threads(struct text_object *, char *, int); void print_threads(struct text_object *, char *, int); +void print_buffers(struct text_object *, char *, int); +void print_cached(struct text_object *, char *, int); + #endif /* _COMMON_H */ diff --git a/src/conky.c b/src/conky.c index a2d10ae4..4816ddcd 100644 --- a/src/conky.c +++ b/src/conky.c @@ -865,12 +865,6 @@ void generate_text_internal(char *p, int p_max_size, } #endif /* __OpenBSD__ */ - OBJ(buffers) { - human_readable(cur->buffers * 1024, p, 255); - } - OBJ(cached) { - human_readable(cur->cached * 1024, p, 255); - } OBJ(cmdline_to_pid) { print_cmdline_to_pid(obj, p, p_max_size); } diff --git a/src/core.c b/src/core.c index 6156afeb..08f9b86c 100644 --- a/src/core.c +++ b/src/core.c @@ -377,7 +377,9 @@ struct text_object *construct_text_object(const char *s, const char *arg, long obj->callbacks.print = &get_obsd_product; #endif /* __OpenBSD__ */ END OBJ(buffers, &update_meminfo) + obj->callbacks.print = &print_buffers; END OBJ(cached, &update_meminfo) + obj->callbacks.print = &print_cached; #define SCAN_CPU(__arg, __var) { \ int __offset = 0; \ if (__arg && sscanf(__arg, " cpu%d %n", &__var, &__offset) > 0) \