1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-23 19:39:06 +00:00

fixing problem where p_max_size becomes <1

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1020 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Brenden Matthews 2008-03-20 20:56:13 +00:00
parent 46e129e7b1
commit 4fe68fcc04
2 changed files with 14 additions and 7 deletions

View File

@ -975,6 +975,9 @@ static int spaced_print(char *buf, int size, char *format, int width,
char *func_name, ...) {
int len;
va_list argp;
if (size < 1) {
return 0;
}
char *tempbuf = malloc(size * sizeof(char));
// Passes the varargs along to vsnprintf
@ -4076,6 +4079,10 @@ static void generate_text_internal(char *p, int p_max_size,
for (i = 0; i < object_count; i++) {
struct text_object *obj = &objs[i];
if (p_max_size < 1) {
break;
};
#define OBJ(a) break; case OBJ_##a:
switch (obj->type) {

View File

@ -86,16 +86,16 @@ static int getsysctl(char *name, void *ptr, size_t len)
struct ifmibdata *data = NULL;
size_t len = 0;
static int swapmode(int *retavail, int *retfree)
static int swapmode(unsigned long *retavail, unsigned long *retfree)
{
int n;
int pagesize = getpagesize();
unsigned long pagesize = getpagesize();
struct kvm_swap swapary[1];
*retavail = 0;
*retfree = 0;
#define CONVERT(v) ((quad_t) (v) * pagesize / 1024)
#define CONVERT(v) ((quad_t)(v) * (pagesize / 1024))
n = kvm_getswapinfo(kd, swapary, 1, 0);
if (n < 0 || swapary[0].ksw_total == 0) {
@ -149,8 +149,8 @@ int check_mount(char *s)
void update_meminfo()
{
int total_pages, inactive_pages, free_pages;
int swap_avail, swap_free;
unsigned long total_pages, inactive_pages, free_pages;
unsigned long swap_avail, swap_free;
int pagesize = getpagesize();
@ -166,8 +166,8 @@ void update_meminfo()
fprintf(stderr, "Cannot read sysctl \"vm.stats.vm.v_inactive_count\"");
}
info.memmax = (total_pages * pagesize) >> 10;
info.mem = ((total_pages - free_pages - inactive_pages) * pagesize) >> 10;
info.memmax = total_pages * (pagesize >> 10);
info.mem = (total_pages - free_pages - inactive_pages) * (pagesize >> 10);
if ((swapmode(&swap_avail, &swap_free)) >= 0) {
info.swapmax = swap_avail;