diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2010-06-02 22:20:40 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2010-06-02 22:20:40 +0200 |
commit | acb60628f53ba1fc29d1a554683acdb03f961c6f (patch) | |
tree | be767e6d7995dee6708b7530b7dabe74d23b491e /lib/mempool.c | |
parent | 4461b8979143bd13024663622c419646a1db0c85 (diff) |
Implements command that shows memory usage.
Diffstat (limited to 'lib/mempool.c')
-rw-r--r-- | lib/mempool.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/mempool.c b/lib/mempool.c index 0cb06b58..65072f9a 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -43,13 +43,15 @@ struct linpool { static void lp_free(resource *); static void lp_dump(resource *); static resource *lp_lookup(resource *, unsigned long); +static size_t lp_memsize(resource *r); static struct resclass lp_class = { "LinPool", sizeof(struct linpool), lp_free, lp_dump, - lp_lookup + lp_lookup, + lp_memsize }; /** @@ -235,6 +237,24 @@ lp_dump(resource *r) m->total_large); } +static size_t +lp_memsize(resource *r) +{ + linpool *m = (linpool *) r; + struct lp_chunk *c; + int cnt = 0; + + for(c=m->first; c; c=c->next) + cnt++; + for(c=m->first_large; c; c=c->next) + cnt++; + + return ALLOC_OVERHEAD + sizeof(struct linpool) + + cnt * (ALLOC_OVERHEAD + sizeof(sizeof(struct lp_chunk))) + + m->total + m->total_large; +} + + static resource * lp_lookup(resource *r, unsigned long a) { |