diff options
-rw-r--r-- | include/whowas.h | 2 | ||||
-rw-r--r-- | modules/m_stats.c | 2 | ||||
-rw-r--r-- | src/watch.c | 10 | ||||
-rw-r--r-- | src/whowas.c | 21 |
4 files changed, 14 insertions, 21 deletions
diff --git a/include/whowas.h b/include/whowas.h index 561192c..2b6bfbd 100644 --- a/include/whowas.h +++ b/include/whowas.h @@ -77,6 +77,6 @@ extern struct Client *get_history(const char *, time_t); /* ** for debugging...counts related structures stored in whowas array. */ -extern void count_whowas_memory(unsigned int *, uint64_t *); +extern void whowas_count_memory(unsigned int *const, uint64_t *const); extern dlink_list WHOWASHASH[]; #endif /* INCLUDED_whowas_h */ diff --git a/modules/m_stats.c b/modules/m_stats.c index 447e8ab..5305f33 100644 --- a/modules/m_stats.c +++ b/modules/m_stats.c @@ -453,7 +453,7 @@ stats_memory(struct Client *source_p, int parc, char *parv[]) /* count up all classes */ class_count = dlink_list_length(class_get_list()); - count_whowas_memory(&wwu, &wwm); + whowas_count_memory(&wwu, &wwm); watch_count_memory(&watch_list_headers, &watch_list_memory); sendto_one(source_p, ":%s %d %s z :WATCH headers %u(%llu) entries %d(%u)", diff --git a/src/watch.c b/src/watch.c index aeb3a30..1722fed 100644 --- a/src/watch.c +++ b/src/watch.c @@ -66,14 +66,14 @@ watch_init(void) /*! \brief Counts up memory used by watch list headers */ void -watch_count_memory(unsigned int *const count, uint64_t *const memory) +watch_count_memory(unsigned int *const count, uint64_t *const bytes) { - unsigned int idx; + unsigned int idx = 0; - for (idx = 0; idx < HASHSIZE; ++idx) - *count += dlink_list_length(&watchTable[idx]); + for (; idx < HASHSIZE; ++idx) + (*count) += dlink_list_length(&watchTable[idx]); - *memory = *count * sizeof(struct Watch); + (*bytes) = *count * sizeof(struct Watch); } /*! \brief Notifies all clients that have client_p's nick name on diff --git a/src/whowas.c b/src/whowas.c index 2df8933..550d461 100644 --- a/src/whowas.c +++ b/src/whowas.c @@ -119,24 +119,17 @@ get_history(const char *nick, time_t timelimit) } void -count_whowas_memory(unsigned int *wwu, uint64_t *wwum) +whowas_count_memory(unsigned int *const count, uint64_t *const bytes) { - const struct Whowas *tmp; - int i; - unsigned int u = 0; - uint64_t um = 0; - - /* count the number of used whowas structs in 'u' */ - /* count up the memory used of whowas structs in um */ - for (i = 0, tmp = &WHOWAS[0]; i < NICKNAMEHISTORYLENGTH; ++i, ++tmp) + const struct Whowas *tmp = &WHOWAS[0]; + unsigned int i = 0; + + for (; i < NICKNAMEHISTORYLENGTH; ++i, ++tmp) { if (tmp->hashv != -1) { - ++u; - um += sizeof(struct Whowas); + (*count)++; + (*bytes) += sizeof(struct Whowas); } } - - *wwu = u; - *wwum = um; } |