diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-06-26 18:15:42 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-06-26 18:15:42 +0200 |
commit | 19bc95b96189de5a645adbe7b3487d5de1b835e7 (patch) | |
tree | b68d3d98d3d643bc02fba218db7f7ed6cd07ea2c /src/gui/gui-nicklist.c | |
parent | 2a630031fd3c868733e3038c3e19ad4b53a8d8ce (diff) | |
download | weechat-19bc95b96189de5a645adbe7b3487d5de1b835e7.zip |
core: many improvements on hdata
New features:
- add optional hdata name for variables in hdata
- add plugin API functions: hdata_get_var_hdata
- use hashtable to store hdata (created by WeeChat and plugins)
- free hdata and infolists created by plugin on plugin unload
- free all hdata on exit
- add "free" option to command /debug hdata
- remove hdata for hooks
Diffstat (limited to 'src/gui/gui-nicklist.c')
-rw-r--r-- | src/gui/gui-nicklist.c | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/src/gui/gui-nicklist.c b/src/gui/gui-nicklist.c index a1dc61dab..ce3c332aa 100644 --- a/src/gui/gui-nicklist.c +++ b/src/gui/gui-nicklist.c @@ -48,10 +48,6 @@ #include "gui-color.h" -struct t_hdata *gui_nicklist_hdata_nick_group = NULL; -struct t_hdata *gui_nicklist_hdata_nick = NULL; - - /* * gui_nicklist_send_signal: send a signal when something has changed in * nicklist @@ -957,26 +953,22 @@ gui_nicklist_hdata_nick_group_cb (void *data, const char *hdata_name) /* make C compiler happy */ (void) data; - if (gui_nicklist_hdata_nick_group) - return gui_nicklist_hdata_nick_group; - - hdata = hdata_new (hdata_name, "prev_group", "next_group"); + hdata = hdata_new (NULL, hdata_name, "prev_group", "next_group"); if (hdata) { - gui_nicklist_hdata_nick_group = hdata; - HDATA_VAR(struct t_gui_nick_group, name, STRING); - HDATA_VAR(struct t_gui_nick_group, color, STRING); - HDATA_VAR(struct t_gui_nick_group, visible, INTEGER); - HDATA_VAR(struct t_gui_nick_group, level, INTEGER); - HDATA_VAR(struct t_gui_nick_group, parent, POINTER); - HDATA_VAR(struct t_gui_nick_group, childs, POINTER); - HDATA_VAR(struct t_gui_nick_group, last_child, POINTER); - HDATA_VAR(struct t_gui_nick_group, nicks, POINTER); - HDATA_VAR(struct t_gui_nick_group, last_nick, POINTER); - HDATA_VAR(struct t_gui_nick_group, prev_group, POINTER); - HDATA_VAR(struct t_gui_nick_group, next_group, POINTER); + HDATA_VAR(struct t_gui_nick_group, name, STRING, NULL); + HDATA_VAR(struct t_gui_nick_group, color, STRING, NULL); + HDATA_VAR(struct t_gui_nick_group, visible, INTEGER, NULL); + HDATA_VAR(struct t_gui_nick_group, level, INTEGER, NULL); + HDATA_VAR(struct t_gui_nick_group, parent, POINTER, hdata_name); + HDATA_VAR(struct t_gui_nick_group, childs, POINTER, hdata_name); + HDATA_VAR(struct t_gui_nick_group, last_child, POINTER, hdata_name); + HDATA_VAR(struct t_gui_nick_group, nicks, POINTER, "nick"); + HDATA_VAR(struct t_gui_nick_group, last_nick, POINTER, "nick"); + HDATA_VAR(struct t_gui_nick_group, prev_group, POINTER, hdata_name); + HDATA_VAR(struct t_gui_nick_group, next_group, POINTER, hdata_name); } - return gui_nicklist_hdata_nick_group; + return hdata; } /* @@ -991,23 +983,19 @@ gui_nicklist_hdata_nick_cb (void *data, const char *hdata_name) /* make C compiler happy */ (void) data; - if (gui_nicklist_hdata_nick) - return gui_nicklist_hdata_nick; - - hdata = hdata_new (hdata_name, "prev_nick", "next_nick"); + hdata = hdata_new (NULL, hdata_name, "prev_nick", "next_nick"); if (hdata) { - gui_nicklist_hdata_nick = hdata; - HDATA_VAR(struct t_gui_nick, group, POINTER); - HDATA_VAR(struct t_gui_nick, name, STRING); - HDATA_VAR(struct t_gui_nick, color, STRING); - HDATA_VAR(struct t_gui_nick, prefix, STRING); - HDATA_VAR(struct t_gui_nick, prefix_color, STRING); - HDATA_VAR(struct t_gui_nick, visible, INTEGER); - HDATA_VAR(struct t_gui_nick, prev_nick, POINTER); - HDATA_VAR(struct t_gui_nick, next_nick, POINTER); + HDATA_VAR(struct t_gui_nick, group, POINTER, "nick_group"); + HDATA_VAR(struct t_gui_nick, name, STRING, NULL); + HDATA_VAR(struct t_gui_nick, color, STRING, NULL); + HDATA_VAR(struct t_gui_nick, prefix, STRING, NULL); + HDATA_VAR(struct t_gui_nick, prefix_color, STRING, NULL); + HDATA_VAR(struct t_gui_nick, visible, INTEGER, NULL); + HDATA_VAR(struct t_gui_nick, prev_nick, POINTER, hdata_name); + HDATA_VAR(struct t_gui_nick, next_nick, POINTER, hdata_name); } - return gui_nicklist_hdata_nick; + return hdata; } /* |