diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-05-24 18:03:14 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-05-24 18:03:14 +0200 |
commit | 7aaf3be15bdb3ff2bd9815cc35bd1699c20ce7a6 (patch) | |
tree | db50043debf82a51dbab4c73f27342dec36d2fee /src | |
parent | 3092c09bc96438afb005c6ce11b07309a945ebc7 (diff) | |
download | weechat-7aaf3be15bdb3ff2bd9815cc35bd1699c20ce7a6.zip |
api: add argument "flags" in function hdata_new_list
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-config-file.c | 4 | ||||
-rw-r--r-- | src/core/wee-hdata.c | 121 | ||||
-rw-r--r-- | src/core/wee-hdata.h | 11 | ||||
-rw-r--r-- | src/core/wee-proxy.c | 4 | ||||
-rw-r--r-- | src/gui/gui-bar-item.c | 4 | ||||
-rw-r--r-- | src/gui/gui-bar.c | 4 | ||||
-rw-r--r-- | src/gui/gui-buffer.c | 10 | ||||
-rw-r--r-- | src/gui/gui-filter.c | 4 | ||||
-rw-r--r-- | src/gui/gui-history.c | 4 | ||||
-rw-r--r-- | src/gui/gui-hotlist.c | 4 | ||||
-rw-r--r-- | src/gui/gui-key.c | 8 | ||||
-rw-r--r-- | src/gui/gui-layout.c | 6 | ||||
-rw-r--r-- | src/gui/gui-window.c | 8 | ||||
-rw-r--r-- | src/plugins/irc/irc-ignore.c | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-redirect.c | 4 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 4 | ||||
-rw-r--r-- | src/plugins/plugin-script.c | 5 | ||||
-rw-r--r-- | src/plugins/plugin.c | 4 | ||||
-rw-r--r-- | src/plugins/script/script-repo.c | 4 | ||||
-rw-r--r-- | src/plugins/weechat-plugin.h | 15 |
20 files changed, 173 insertions, 59 deletions
diff --git a/src/core/wee-config-file.c b/src/core/wee-config-file.c index 0017a2c2b..7c313ee16 100644 --- a/src/core/wee-config-file.c +++ b/src/core/wee-config-file.c @@ -2718,8 +2718,8 @@ config_file_hdata_config_file_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_config_file, last_section, POINTER, 0, NULL, "config_section"); HDATA_VAR(struct t_config_file, prev_config, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_config_file, next_config, POINTER, 0, NULL, hdata_name); - HDATA_LIST(config_files); - HDATA_LIST(last_config_file); + HDATA_LIST(config_files, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_config_file, 0); } return hdata; } diff --git a/src/core/wee-hdata.c b/src/core/wee-hdata.c index c13f92e2c..a96956ebb 100644 --- a/src/core/wee-hdata.c +++ b/src/core/wee-hdata.c @@ -73,6 +73,21 @@ hdata_free_var (struct t_hashtable *hashtable, } /* + * Frees a hdata list. + */ + +void +hdata_free_list (struct t_hashtable *hashtable, + const void *key, void *value) +{ + /* make C compiler happy */ + (void) hashtable; + (void) key; + + free (value); +} + +/* * Creates a new hdata. * * Returns pointer to new hdata, NULL if error. @@ -111,6 +126,7 @@ hdata_new (struct t_weechat_plugin *plugin, const char *hdata_name, WEECHAT_HASHTABLE_POINTER, NULL, NULL); + new_hdata->hash_list->callback_free_value = &hdata_free_list; hashtable_set (weechat_hdata, hdata_name, new_hdata); new_hdata->create_allowed = create_allowed; new_hdata->delete_allowed = delete_allowed; @@ -153,12 +169,21 @@ hdata_new_var (struct t_hdata *hdata, const char *name, int offset, int type, */ void -hdata_new_list (struct t_hdata *hdata, const char *name, void *pointer) +hdata_new_list (struct t_hdata *hdata, const char *name, void *pointer, + int flags) { + struct t_hdata_list *list; + if (!hdata || !name) return; - hashtable_set (hdata->hash_list, name, pointer); + list = malloc (sizeof (*list)); + if (list) + { + list->pointer = pointer; + list->flags = flags; + hashtable_set (hdata->hash_list, name, list); + } } /* @@ -399,20 +424,20 @@ hdata_get_var_at_offset (struct t_hdata *hdata, void *pointer, int offset) void * hdata_get_list (struct t_hdata *hdata, const char *name) { - void *ptr_value; + struct t_hdata_list *ptr_list; if (!hdata || !name) return NULL; - ptr_value = hashtable_get (hdata->hash_list, name); - if (ptr_value) - return *((void **)ptr_value); + ptr_list = hashtable_get (hdata->hash_list, name); + if (ptr_list) + return *((void **)(ptr_list->pointer)); return NULL; } /* - * Checks if a pointer is valid for a given hdata/list. + * Checks if a pointer is in the list. * * Returns: * 1: pointer exists in list @@ -420,15 +445,16 @@ hdata_get_list (struct t_hdata *hdata, const char *name) */ int -hdata_check_pointer (struct t_hdata *hdata, void *list, void *pointer) +hdata_check_pointer_in_list (struct t_hdata *hdata, void *list, void *pointer) { void *ptr_current; - if (!hdata || !list || !pointer) + if (!hdata || !pointer) return 0; if (pointer == list) return 1; + ptr_current = list; while (ptr_current) { @@ -441,6 +467,83 @@ hdata_check_pointer (struct t_hdata *hdata, void *list, void *pointer) } /* + * Checks if a pointer is in a list with flag "check_pointers". + */ + +void +hdata_check_pointer_map_cb (void *data, struct t_hashtable *hashtable, + const void *key, const void *value) +{ + void **pointers, *pointer, **num_lists, **found; + struct t_hdata *ptr_hdata; + struct t_hdata_list *ptr_list; + + /* make C compiler happy */ + (void) hashtable; + (void) key; + + pointers = (void **)data; + ptr_hdata = pointers[0]; + pointer = pointers[1]; + num_lists = &pointers[2]; + found = &pointers[3]; + + /* pointer already found in another list? just exit */ + if (*found) + return; + + ptr_list = (struct t_hdata_list *)value; + if (!ptr_list || !(ptr_list->flags & WEECHAT_HDATA_LIST_CHECK_POINTERS)) + return; + + *found = (void *)((unsigned long int)hdata_check_pointer_in_list ( + ptr_hdata, + *((void **)(ptr_list->pointer)), + pointer)); + (*num_lists)++; +} + +/* + * Checks if a pointer is valid for a given hdata/list. + * + * If argument "list" is NULL, the check is made with all lists in hdata + * that have flag "check_pointers". If no list is defined with this flag, + * the pointer is considered valid (so this function returns 1); if the + * pointer is not found in any list, this function returns 0. + * + * Returns: + * 1: pointer exists in the given list (or a list with check_pointers flag) + * 0: pointer does not exist + */ + +int +hdata_check_pointer (struct t_hdata *hdata, void *list, void *pointer) +{ + void *pointers[4]; + + if (!hdata || !pointer) + return 0; + + if (list) + { + /* search pointer in the given list */ + return hdata_check_pointer_in_list (hdata, list, pointer); + } + else + { + /* search pointer in all lists with flag "check_pointers" */ + pointers[0] = hdata; + pointers[1] = pointer; + pointers[2] = 0; /* number of lists with flag check_pointers */ + pointers[3] = 0; /* pointer found? (0/1) */ + hashtable_map (hdata->hash_list, + &hdata_check_pointer_map_cb, + pointers); + return ((pointers[2] == 0) || pointers[3]) ? 1 : 0; + } +} + +/* * Moves pointer to another element in list. */ diff --git a/src/core/wee-hdata.h b/src/core/wee-hdata.h index abbd505e9..68523f8d4 100644 --- a/src/core/wee-hdata.h +++ b/src/core/wee-hdata.h @@ -25,7 +25,8 @@ hdata_new_var (hdata, #__name, offsetof (__struct, __name), \ WEECHAT_HDATA_##__type, __update_allowed, \ __array_size, __hdata_name) -#define HDATA_LIST(__name) hdata_new_list (hdata, #__name, &(__name)); +#define HDATA_LIST(__name, __flags) \ + hdata_new_list (hdata, #__name, &(__name), __flags); struct t_hdata_var { @@ -36,6 +37,12 @@ struct t_hdata_var char *hdata_name; /* hdata name */ }; +struct t_hdata_list +{ + void *pointer; /* list pointer */ + int flags; /* flags for list */ +}; + struct t_hdata { char *name; /* name of hdata */ @@ -79,7 +86,7 @@ extern void hdata_new_var (struct t_hdata *hdata, const char *name, int offset, int type, int update_allowed, const char *array_size, const char *hdata_name); extern void hdata_new_list (struct t_hdata *hdata, const char *name, - void *pointer); + void *pointer, int flags); extern int hdata_get_var_offset (struct t_hdata *hdata, const char *name); extern int hdata_get_var_type (struct t_hdata *hdata, const char *name); extern const char *hdata_get_var_type_string (struct t_hdata *hdata, diff --git a/src/core/wee-proxy.c b/src/core/wee-proxy.c index 08b6190a4..34b16b97c 100644 --- a/src/core/wee-proxy.c +++ b/src/core/wee-proxy.c @@ -636,8 +636,8 @@ proxy_hdata_proxy_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_proxy, options, POINTER, 0, NULL, NULL); HDATA_VAR(struct t_proxy, prev_proxy, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_proxy, next_proxy, POINTER, 0, NULL, hdata_name); - HDATA_LIST(weechat_proxies); - HDATA_LIST(last_weechat_proxy); + HDATA_LIST(weechat_proxies, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_weechat_proxy, 0); } return hdata; } diff --git a/src/gui/gui-bar-item.c b/src/gui/gui-bar-item.c index 3c72973ba..4f6d74264 100644 --- a/src/gui/gui-bar-item.c +++ b/src/gui/gui-bar-item.c @@ -2174,8 +2174,8 @@ gui_bar_item_hdata_bar_item_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_bar_item, build_callback_data, POINTER, 0, NULL, NULL); HDATA_VAR(struct t_gui_bar_item, prev_item, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_bar_item, next_item, POINTER, 0, NULL, hdata_name); - HDATA_LIST(gui_bar_items); - HDATA_LIST(last_gui_bar_item); + HDATA_LIST(gui_bar_items, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_gui_bar_item, 0); } return hdata; } diff --git a/src/gui/gui-bar.c b/src/gui/gui-bar.c index 2d255ba8c..58ed2c52b 100644 --- a/src/gui/gui-bar.c +++ b/src/gui/gui-bar.c @@ -2280,8 +2280,8 @@ gui_bar_hdata_bar_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_bar, bar_refresh_needed, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_bar, prev_bar, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_bar, next_bar, POINTER, 0, NULL, hdata_name); - HDATA_LIST(gui_bars); - HDATA_LIST(last_gui_bar); + HDATA_LIST(gui_bars, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_gui_bar, 0); } return hdata; } diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index ae4a2a995..2bc130961 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -4024,9 +4024,9 @@ gui_buffer_hdata_buffer_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_buffer, local_variables, HASHTABLE, 0, NULL, NULL); HDATA_VAR(struct t_gui_buffer, prev_buffer, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_buffer, next_buffer, POINTER, 0, NULL, hdata_name); - HDATA_LIST(gui_buffers); - HDATA_LIST(last_gui_buffer); - HDATA_LIST(gui_buffer_last_displayed); + HDATA_LIST(gui_buffers, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_gui_buffer, 0); + HDATA_LIST(gui_buffer_last_displayed, 0); } return hdata; } @@ -4074,8 +4074,8 @@ gui_buffer_hdata_buffer_visited_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_buffer_visited, buffer, POINTER, 0, NULL, "buffer"); HDATA_VAR(struct t_gui_buffer_visited, prev_buffer, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_buffer_visited, next_buffer, POINTER, 0, NULL, hdata_name); - HDATA_LIST(gui_buffers_visited); - HDATA_LIST(last_gui_buffer_visited); + HDATA_LIST(gui_buffers_visited, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_gui_buffer_visited, 0); } return hdata; } diff --git a/src/gui/gui-filter.c b/src/gui/gui-filter.c index b435e829b..de6005405 100644 --- a/src/gui/gui-filter.c +++ b/src/gui/gui-filter.c @@ -516,8 +516,8 @@ gui_filter_hdata_filter_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_filter, regex_message, POINTER, 0, NULL, NULL); HDATA_VAR(struct t_gui_filter, prev_filter, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_filter, next_filter, POINTER, 0, NULL, hdata_name); - HDATA_LIST(gui_filters); - HDATA_LIST(last_gui_filter); + HDATA_LIST(gui_filters, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_gui_filter, 0); } return hdata; } diff --git a/src/gui/gui-history.c b/src/gui/gui-history.c index cd8f02966..b3e415cf8 100644 --- a/src/gui/gui-history.c +++ b/src/gui/gui-history.c @@ -291,8 +291,8 @@ gui_history_hdata_history_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_history, text, STRING, 0, NULL, NULL); HDATA_VAR(struct t_gui_history, prev_history, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_history, next_history, POINTER, 0, NULL, hdata_name); - HDATA_LIST(gui_history); - HDATA_LIST(last_gui_history); + HDATA_LIST(gui_history, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_gui_history, 0); } return hdata; } diff --git a/src/gui/gui-hotlist.c b/src/gui/gui-hotlist.c index 3f8dbd319..a28f596f3 100644 --- a/src/gui/gui-hotlist.c +++ b/src/gui/gui-hotlist.c @@ -540,8 +540,8 @@ gui_hotlist_hdata_hotlist_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_hotlist, count, INTEGER, 0, GUI_HOTLIST_NUM_PRIORITIES_STR, NULL); HDATA_VAR(struct t_gui_hotlist, prev_hotlist, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_hotlist, next_hotlist, POINTER, 0, NULL, hdata_name); - HDATA_LIST(gui_hotlist); - HDATA_LIST(last_gui_hotlist); + HDATA_LIST(gui_hotlist, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_gui_hotlist, 0); } return hdata; } diff --git a/src/gui/gui-key.c b/src/gui/gui-key.c index daf0cae17..2b408a129 100644 --- a/src/gui/gui-key.c +++ b/src/gui/gui-key.c @@ -1871,22 +1871,22 @@ gui_key_hdata_key_cb (void *data, const char *hdata_name) "gui_keys%s%s", (i == GUI_KEY_CONTEXT_DEFAULT) ? "" : "_", (i == GUI_KEY_CONTEXT_DEFAULT) ? "" : gui_key_context_string[i]); - hdata_new_list(hdata, str_list, &gui_keys[i]); + hdata_new_list(hdata, str_list, &gui_keys[i], 0); snprintf (str_list, sizeof (str_list), "last_gui_key%s%s", (i == GUI_KEY_CONTEXT_DEFAULT) ? "" : "_", (i == GUI_KEY_CONTEXT_DEFAULT) ? "" : gui_key_context_string[i]); - hdata_new_list(hdata, str_list, &last_gui_key[i]); + hdata_new_list(hdata, str_list, &last_gui_key[i], 0); snprintf (str_list, sizeof (str_list), "gui_default_keys%s%s", (i == GUI_KEY_CONTEXT_DEFAULT) ? "" : "_", (i == GUI_KEY_CONTEXT_DEFAULT) ? "" : gui_key_context_string[i]); - hdata_new_list(hdata, str_list, &gui_default_keys[i]); + hdata_new_list(hdata, str_list, &gui_default_keys[i], 0); snprintf (str_list, sizeof (str_list), "last_gui_default_key%s%s", (i == GUI_KEY_CONTEXT_DEFAULT) ? "" : "_", (i == GUI_KEY_CONTEXT_DEFAULT) ? "" : gui_key_context_string[i]); - hdata_new_list(hdata, str_list, &last_gui_default_key[i]); + hdata_new_list(hdata, str_list, &last_gui_default_key[i], 0); } } return hdata; diff --git a/src/gui/gui-layout.c b/src/gui/gui-layout.c index 4ca76d213..d7bf7179a 100644 --- a/src/gui/gui-layout.c +++ b/src/gui/gui-layout.c @@ -954,9 +954,9 @@ gui_layout_hdata_layout_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_layout, internal_id_current_window, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_gui_layout, prev_layout, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_layout, next_layout, POINTER, 0, NULL, hdata_name); - HDATA_LIST(gui_layouts); - HDATA_LIST(last_gui_layout); - HDATA_LIST(gui_layout_current); + HDATA_LIST(gui_layouts, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_gui_layout, 0); + HDATA_LIST(gui_layout_current, 0); } return hdata; } diff --git a/src/gui/gui-window.c b/src/gui/gui-window.c index 7345e669f..e368636a9 100644 --- a/src/gui/gui-window.c +++ b/src/gui/gui-window.c @@ -1760,9 +1760,9 @@ gui_window_hdata_window_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_window, ptr_tree, POINTER, 0, NULL, "window_tree"); HDATA_VAR(struct t_gui_window, prev_window, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_window, next_window, POINTER, 0, NULL, hdata_name); - HDATA_LIST(gui_windows); - HDATA_LIST(last_gui_window); - HDATA_LIST(gui_current_window); + HDATA_LIST(gui_windows, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_gui_window, 0); + HDATA_LIST(gui_current_window, 0); } return hdata; } @@ -1817,7 +1817,7 @@ gui_window_hdata_window_tree_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_gui_window_tree, child1, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_window_tree, child2, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_gui_window_tree, window, POINTER, 0, NULL, "window"); - HDATA_LIST(gui_windows_tree); + HDATA_LIST(gui_windows_tree, 0); } return hdata; } diff --git a/src/plugins/irc/irc-ignore.c b/src/plugins/irc/irc-ignore.c index 2292a16e6..1ae57eeeb 100644 --- a/src/plugins/irc/irc-ignore.c +++ b/src/plugins/irc/irc-ignore.c @@ -326,8 +326,8 @@ irc_ignore_hdata_ignore_cb (void *data, const char *hdata_name) WEECHAT_HDATA_VAR(struct t_irc_ignore, channel, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_ignore, prev_ignore, POINTER, 0, NULL, hdata_name); WEECHAT_HDATA_VAR(struct t_irc_ignore, next_ignore, POINTER, 0, NULL, hdata_name); - WEECHAT_HDATA_LIST(irc_ignore_list); - WEECHAT_HDATA_LIST(last_irc_ignore); + WEECHAT_HDATA_LIST(irc_ignore_list, WEECHAT_HDATA_LIST_CHECK_POINTERS); + WEECHAT_HDATA_LIST(last_irc_ignore, 0); } return hdata; } diff --git a/src/plugins/irc/irc-redirect.c b/src/plugins/irc/irc-redirect.c index 2d3ab5456..553507967 100644 --- a/src/plugins/irc/irc-redirect.c +++ b/src/plugins/irc/irc-redirect.c @@ -1007,8 +1007,8 @@ irc_redirect_hdata_redirect_pattern_cb (void *data, const char *hdata_name) WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, cmd_extra, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, prev_redirect, POINTER, 0, NULL, hdata_name); WEECHAT_HDATA_VAR(struct t_irc_redirect_pattern, next_redirect, POINTER, 0, NULL, hdata_name); - WEECHAT_HDATA_LIST(irc_redirect_patterns); - WEECHAT_HDATA_LIST(last_irc_redirect_pattern); + WEECHAT_HDATA_LIST(irc_redirect_patterns, WEECHAT_HDATA_LIST_CHECK_POINTERS); + WEECHAT_HDATA_LIST(last_irc_redirect_pattern, 0); } return hdata; } diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index b56451fab..a18f0ec5b 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -4904,8 +4904,8 @@ irc_server_hdata_server_cb (void *data, const char *hdata_name) WEECHAT_HDATA_VAR(struct t_irc_server, last_channel, POINTER, 0, NULL, "irc_channel"); WEECHAT_HDATA_VAR(struct t_irc_server, prev_server, POINTER, 0, NULL, hdata_name); WEECHAT_HDATA_VAR(struct t_irc_server, next_server, POINTER, 0, NULL, hdata_name); - WEECHAT_HDATA_LIST(irc_servers); - WEECHAT_HDATA_LIST(last_irc_server); + WEECHAT_HDATA_LIST(irc_servers, WEECHAT_HDATA_LIST_CHECK_POINTERS); + WEECHAT_HDATA_LIST(last_irc_server, 0); } return hdata; } diff --git a/src/plugins/plugin-script.c b/src/plugins/plugin-script.c index bffe58e75..678ec1454 100644 --- a/src/plugins/plugin-script.c +++ b/src/plugins/plugin-script.c @@ -1380,8 +1380,9 @@ plugin_script_hdata_script (struct t_weechat_plugin *weechat_plugin, WEECHAT_HDATA_VAR(struct t_plugin_script, unloading, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_plugin_script, prev_script, POINTER, 0, NULL, hdata_name); WEECHAT_HDATA_VAR(struct t_plugin_script, next_script, POINTER, 0, NULL, hdata_name); - weechat_hdata_new_list (hdata, "scripts", scripts); - weechat_hdata_new_list (hdata, "last_script", last_script); + weechat_hdata_new_list (hdata, "scripts", scripts, + WEECHAT_HDATA_LIST_CHECK_POINTERS); + weechat_hdata_new_list (hdata, "last_script", last_script, 0); } return hdata; } diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index f910c8fdc..13eba0a9b 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -1247,8 +1247,8 @@ plugin_hdata_plugin_cb (void *data, const char *hdata_name) HDATA_VAR(struct t_weechat_plugin, debug, INTEGER, 0, NULL, NULL); HDATA_VAR(struct t_weechat_plugin, prev_plugin, POINTER, 0, NULL, hdata_name); HDATA_VAR(struct t_weechat_plugin, next_plugin, POINTER, 0, NULL, hdata_name); - HDATA_LIST(weechat_plugins); - HDATA_LIST(last_weechat_plugin); + HDATA_LIST(weechat_plugins, WEECHAT_HDATA_LIST_CHECK_POINTERS); + HDATA_LIST(last_weechat_plugin, 0); } return hdata; } diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c index b9f868653..bc7756a16 100644 --- a/src/plugins/script/script-repo.c +++ b/src/plugins/script/script-repo.c @@ -1520,8 +1520,8 @@ script_repo_hdata_script_cb (void *data, const char *hdata_name) WEECHAT_HDATA_VAR(struct t_script_repo, install_order, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_script_repo, prev_script, POINTER, 0, NULL, hdata_name); WEECHAT_HDATA_VAR(struct t_script_repo, next_script, POINTER, 0, NULL, hdata_name); - WEECHAT_HDATA_LIST(scripts_repo); - WEECHAT_HDATA_LIST(last_script_repo); + WEECHAT_HDATA_LIST(scripts_repo, WEECHAT_HDATA_LIST_CHECK_POINTERS); + WEECHAT_HDATA_LIST(last_script_repo, 0); } return hdata; } diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index c17d28991..7e491dda2 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -57,7 +57,7 @@ struct timeval; * please change the date with current one; for a second change at same * date, increment the 01, otherwise please keep 01. */ -#define WEECHAT_PLUGIN_API_VERSION "20140313-01" +#define WEECHAT_PLUGIN_API_VERSION "20140524-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -125,6 +125,9 @@ struct timeval; #define WEECHAT_HDATA_HASHTABLE 7 #define WEECHAT_HDATA_SHARED_STRING 8 +/* flags for hdata lists */ +#define WEECHAT_HDATA_LIST_CHECK_POINTERS 1 + /* buffer hotlist */ #define WEECHAT_HOTLIST_LOW "0" #define WEECHAT_HOTLIST_MESSAGE "1" @@ -879,7 +882,7 @@ struct t_weechat_plugin int type, int update_allowed, const char *array_size, const char *hdata_name); void (*hdata_new_list) (struct t_hdata *hdata, const char *name, - void *pointer); + void *pointer, int flags); struct t_hdata *(*hdata_get) (struct t_weechat_plugin *plugin, const char *hdata_name); int (*hdata_get_var_offset) (struct t_hdata *hdata, const char *name); @@ -1685,10 +1688,10 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin); weechat_hdata_new_var (hdata, #__name, offsetof (__struct, __name), \ WEECHAT_HDATA_##__type, __update_allowed, \ __array_size, __hdata_name) -#define weechat_hdata_new_list(__hdata, __name, __pointer) \ - weechat_plugin->hdata_new_list(__hdata, __name, __pointer) -#define WEECHAT_HDATA_LIST(__name) \ - weechat_hdata_new_list (hdata, #__name, &(__name)); +#define weechat_hdata_new_list(__hdata, __name, __pointer, __flags) \ + weechat_plugin->hdata_new_list(__hdata, __name, __pointer, __flags) +#define WEECHAT_HDATA_LIST(__name, __flags) \ + weechat_hdata_new_list (hdata, #__name, &(__name), __flags); #define weechat_hdata_get(__hdata_name) \ weechat_plugin->hdata_get(weechat_plugin, __hdata_name) #define weechat_hdata_get_var_offset(__hdata, __name) \ |