aboutsummaryrefslogtreecommitdiffstats
path: root/plugin_meminfo.c
diff options
context:
space:
mode:
authorreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-06-17 06:23:43 +0000
committerreinelt <reinelt@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>2004-06-17 06:23:43 +0000
commit1d354fd87d4c07906e82d104ba8614d30ae9cbbe (patch)
treeca9aafd446dda125df1411933930669d303c9a30 /plugin_meminfo.c
parente8e56418dc7375b50f36e930fb6752fbe25b4ae1 (diff)
downloadlcd4linux-1d354fd87d4c07906e82d104ba8614d30ae9cbbe.tar.gz
[lcd4linux @ 2004-06-17 06:23:39 by reinelt]
hash handling rewritten to solve performance issues git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@473 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
Diffstat (limited to 'plugin_meminfo.c')
-rw-r--r--plugin_meminfo.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/plugin_meminfo.c b/plugin_meminfo.c
index d9203de..a15565e 100644
--- a/plugin_meminfo.c
+++ b/plugin_meminfo.c
@@ -1,4 +1,4 @@
-/* $Id: plugin_meminfo.c,v 1.7 2004/03/11 06:39:59 reinelt Exp $
+/* $Id: plugin_meminfo.c,v 1.8 2004/06/17 06:23:43 reinelt Exp $
*
* plugin for /proc/meminfo parsing
*
@@ -23,6 +23,10 @@
*
*
* $Log: plugin_meminfo.c,v $
+ * Revision 1.8 2004/06/17 06:23:43 reinelt
+ *
+ * hash handling rewritten to solve performance issues
+ *
* Revision 1.7 2004/03/11 06:39:59 reinelt
* big patch from Martin:
* - reuse filehandles
@@ -82,7 +86,7 @@
#include "hash.h"
-static HASH MemInfo = { 0, };
+static HASH MemInfo;
static FILE *stream = NULL;
static int parse_meminfo (void)
@@ -90,7 +94,7 @@ static int parse_meminfo (void)
int age;
// reread every 10 msec only
- age=hash_age(&MemInfo, NULL, NULL);
+ age=hash_age(&MemInfo, NULL);
if (age>0 && age<=10) return 0;
if (stream==NULL) stream=fopen("/proc/meminfo", "r");
@@ -121,7 +125,7 @@ static int parse_meminfo (void)
// strip trailing " kB" from value
*(c-2)='\0';
// add entry to hash table
- hash_set (&MemInfo, key, val);
+ hash_put (&MemInfo, key, val);
}
}
return 0;
@@ -137,7 +141,7 @@ static void my_meminfo (RESULT *result, RESULT *arg1)
}
key=R2S(arg1);
- val=hash_get(&MemInfo, key);
+ val=hash_get(&MemInfo, key, NULL);
if (val==NULL) val="";
SetResult(&result, R_STRING, val);
@@ -146,6 +150,7 @@ static void my_meminfo (RESULT *result, RESULT *arg1)
int plugin_init_meminfo (void)
{
+ hash_create(&MemInfo);
AddFunction ("meminfo", 1, my_meminfo);
return 0;
}