diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2015-07-15 23:55:00 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2015-07-15 23:55:00 +0200 |
commit | 80872061c273064dcc71d8612eaa6feae78ac246 (patch) | |
tree | 540e37d772375a34ff04351d06b2f0f1e1638b6f | |
parent | e9c6381774f53dd2f00f12961ac01fa2126c205d (diff) | |
download | weechat-80872061c273064dcc71d8612eaa6feae78ac246.zip |
core: add variables with count of hooks
-rw-r--r-- | src/core/wee-debug.c | 16 | ||||
-rw-r--r-- | src/core/wee-hook.c | 10 | ||||
-rw-r--r-- | src/core/wee-hook.h | 2 |
3 files changed, 16 insertions, 12 deletions
diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c index 4abe3042f..bb82027ab 100644 --- a/src/core/wee-debug.c +++ b/src/core/wee-debug.c @@ -391,26 +391,18 @@ debug_hdata () void debug_hooks () { - int i, num_hooks, num_hooks_total; - struct t_hook *ptr_hook; + int i; gui_chat_printf (NULL, ""); gui_chat_printf (NULL, "hooks in memory:"); - num_hooks_total = 0; for (i = 0; i < HOOK_NUM_TYPES; i++) { - num_hooks = 0; - for (ptr_hook = weechat_hooks[i]; ptr_hook; - ptr_hook = ptr_hook->next_hook) - { - num_hooks++; - } - gui_chat_printf (NULL, "%17s:%5d", hook_type_string[i], num_hooks); - num_hooks_total += num_hooks; + gui_chat_printf (NULL, "%17s:%5d", + hook_type_string[i], hooks_count[i]); } gui_chat_printf (NULL, "%17s------", "---------"); - gui_chat_printf (NULL, "%17s:%5d", "total", num_hooks_total); + gui_chat_printf (NULL, "%17s:%5d", "total", hooks_count_total); } /* diff --git a/src/core/wee-hook.c b/src/core/wee-hook.c index 927c2a3c6..161211224 100644 --- a/src/core/wee-hook.c +++ b/src/core/wee-hook.c @@ -68,6 +68,8 @@ char *hook_type_string[HOOK_NUM_TYPES] = "info", "info_hashtable", "infolist", "hdata", "focus" }; struct t_hook *weechat_hooks[HOOK_NUM_TYPES]; /* list of hooks */ struct t_hook *last_weechat_hook[HOOK_NUM_TYPES]; /* last hook */ +int hooks_count[HOOK_NUM_TYPES]; /* number of hooks */ +int hooks_count_total = 0; /* total number of hooks */ int hook_exec_recursion = 0; /* 1 when a hook is executed */ time_t hook_last_system_time = 0; /* used to detect system clock skew */ int real_delete_pending = 0; /* 1 if some hooks must be deleted */ @@ -89,7 +91,9 @@ hook_init () { weechat_hooks[type] = NULL; last_weechat_hook[type] = NULL; + hooks_count[type] = 0; } + hooks_count_total = 0; hook_last_system_time = time (NULL); } @@ -201,6 +205,9 @@ hook_add_to_list (struct t_hook *new_hook) weechat_hooks[new_hook->type] = new_hook; last_weechat_hook[new_hook->type] = new_hook; } + + hooks_count[new_hook->type]++; + hooks_count_total++; } /* @@ -231,6 +238,9 @@ hook_remove_from_list (struct t_hook *hook) free (hook); weechat_hooks[type] = new_hooks; + + hooks_count[type]--; + hooks_count_total--; } /* diff --git a/src/core/wee-hook.h b/src/core/wee-hook.h index 01c9c33c0..f7ab9de62 100644 --- a/src/core/wee-hook.h +++ b/src/core/wee-hook.h @@ -438,6 +438,8 @@ struct t_hook_focus extern char *hook_type_string[]; extern struct t_hook *weechat_hooks[]; extern struct t_hook *last_weechat_hook[]; +extern int hooks_count[]; +extern int hooks_count_total; /* hook functions */ |