diff --git a/src/Makefile b/src/Makefile index 911d5ea9e..3e4069d87 100644 --- a/src/Makefile +++ b/src/Makefile @@ -49,7 +49,7 @@ elinks: $(LIB_O_NAME) vernum.o TAGS: cd $(srcdir) \ && find . \( -name "*.[ch]" -o -name "*.inc" \) -print \ - | etags --regex='{c}/INIT_LIST_HEAD(\([[:alnum:]_]+\))/\1/' \ + | etags --regex='{c}/INIT_LIST_OF([^,]*,[ \t]*\([[:alnum:]_]+\))/\1/' \ --regex='{c}/struct_hierbox_browser(\n[ \t]*\([[:alnum:]_]+\),/\1/m' \ --regex='{c}/^ACTION_(\([[:alnum:]_]+\),[^,]*,[ \t]*\([[:alnum:]_]+\),/ACT_\1_\2/' \ --language=c - diff --git a/src/bfu/hierbox.h b/src/bfu/hierbox.h index 008e94fc1..89da4b28a 100644 --- a/src/bfu/hierbox.h +++ b/src/bfu/hierbox.h @@ -21,8 +21,8 @@ struct hierbox_browser { const struct hierbox_browser_button *buttons; size_t buttons_size; - struct list_head boxes; - struct list_head dialogs; + LIST_OF(struct listbox_data) boxes; + LIST_OF(struct hierbox_dialog_list_item) dialogs; struct listbox_item root; const struct listbox_ops *ops; diff --git a/src/bfu/inpfield.h b/src/bfu/inpfield.h index 2829eb707..d45a90205 100644 --- a/src/bfu/inpfield.h +++ b/src/bfu/inpfield.h @@ -30,7 +30,7 @@ struct widget_info_field { struct widget_data_info_field { int vpos; int cpos; - struct list_head history; + LIST_OF(struct input_history_entry) history; struct input_history_entry *cur_hist; }; diff --git a/src/bfu/inphist.c b/src/bfu/inphist.c index b3b714ab6..8c6d005c5 100644 --- a/src/bfu/inphist.c +++ b/src/bfu/inphist.c @@ -58,7 +58,8 @@ menu_tab_compl(struct terminal *term, void *item_, void *dlg_data_) /* Complete to last unambiguous character, and display menu for all possible * further completions. */ void -do_tab_compl(struct dialog_data *dlg_data, struct list_head *history) +do_tab_compl(struct dialog_data *dlg_data, + LIST_OF(struct input_history_entry) *history) { struct terminal *term = dlg_data->win->term; struct widget_data *widget_data = selected_widget(dlg_data); @@ -104,7 +105,8 @@ strcommonlen(unsigned char *a, unsigned char *b) * completes `go' to `google.com' and `google.com/' to `google.com/search?q='. */ void -do_tab_compl_unambiguous(struct dialog_data *dlg_data, struct list_head *history) +do_tab_compl_unambiguous(struct dialog_data *dlg_data, + LIST_OF(struct input_history_entry) *history) { struct string completion; struct widget_data *widget_data = selected_widget(dlg_data); @@ -188,7 +190,8 @@ tab_complete_file_menu(struct terminal *term, void *path_, void *dlg_data_) } void -do_tab_compl_file(struct dialog_data *dlg_data, struct list_head *history) +do_tab_compl_file(struct dialog_data *dlg_data, + LIST_OF(struct input_history_entry) *history) { struct widget_data *widget_data = selected_widget(dlg_data); diff --git a/src/bfu/inphist.h b/src/bfu/inphist.h index 0011ef9d2..d7a5ecf08 100644 --- a/src/bfu/inphist.h +++ b/src/bfu/inphist.h @@ -12,7 +12,7 @@ struct input_history_entry { }; struct input_history { - struct list_head entries; + LIST_OF(struct input_history_entry) entries; int size; unsigned int dirty:1; unsigned int nosave:1; @@ -42,9 +42,12 @@ struct input_history { void add_to_input_history(struct input_history *, unsigned char *, int); -void do_tab_compl(struct dialog_data *, struct list_head *); -void do_tab_compl_file(struct dialog_data *, struct list_head *); -void do_tab_compl_unambiguous(struct dialog_data *, struct list_head *); +void do_tab_compl(struct dialog_data *, + LIST_OF(struct input_history_entry) *); +void do_tab_compl_file(struct dialog_data *, + LIST_OF(struct input_history_entry) *); +void do_tab_compl_unambiguous(struct dialog_data *, + LIST_OF(struct input_history_entry) *); /* Load history file from elinks home. */ int load_input_history(struct input_history *history, unsigned char *filename); diff --git a/src/bfu/listbox.c b/src/bfu/listbox.c index 66506c940..1406e034e 100644 --- a/src/bfu/listbox.c +++ b/src/bfu/listbox.c @@ -407,7 +407,7 @@ display_listbox_item(struct listbox_item *item, void *data_, int *offset) str[1] = BORDER_SDLCORNER; } } else { - struct list_head *p = data->box->items; + LIST_OF(struct listbox_item) *p = data->box->items; if (p->next == item) { str[1] = BORDER_SULCORNER; diff --git a/src/bfu/listbox.h b/src/bfu/listbox.h index bca2a2662..c3599e586 100644 --- a/src/bfu/listbox.h +++ b/src/bfu/listbox.h @@ -105,7 +105,7 @@ struct listbox_data { struct listbox_item *top; /* Item which is on the top line of the box */ int sel_offset; /* Offset of selected item against the box top */ - struct list_head *items; /* The list being displayed */ + LIST_OF(struct listbox_item) *items; /* The list being displayed */ }; enum listbox_item_type { @@ -119,7 +119,7 @@ struct listbox_item { LIST_HEAD(struct listbox_item); /* The list may be empty for leaf nodes or non-hiearchic listboxes */ - struct list_head child; + LIST_OF(struct listbox_item) child; enum listbox_item_type type; int depth; diff --git a/src/bookmarks/backend/common.c b/src/bookmarks/backend/common.c index 0890bbd45..4d386cdd8 100644 --- a/src/bookmarks/backend/common.c +++ b/src/bookmarks/backend/common.c @@ -74,7 +74,7 @@ bookmarks_read(void) } void -bookmarks_write(struct list_head *bookmarks_list) +bookmarks_write(LIST_OF(struct bookmark) *bookmarks_list) { int backend_num = get_opt_int("bookmarks.file_format"); struct bookmarks_backend *backend = bookmarks_backends[backend_num]; diff --git a/src/bookmarks/backend/common.h b/src/bookmarks/backend/common.h index 6dec16c78..f406aa3c4 100644 --- a/src/bookmarks/backend/common.h +++ b/src/bookmarks/backend/common.h @@ -10,10 +10,10 @@ struct bookmarks_backend { /* Order matters here. --Zas. */ unsigned char *(*filename)(int); void (*read)(FILE *); - void (*write)(struct secure_save_info *, struct list_head *); + void (*write)(struct secure_save_info *, LIST_OF(struct bookmark) *); }; void bookmarks_read(void); -void bookmarks_write(struct list_head *); +void bookmarks_write(LIST_OF(struct bookmark) *); #endif diff --git a/src/bookmarks/backend/default.c b/src/bookmarks/backend/default.c index f68d1c643..a098b7d3f 100644 --- a/src/bookmarks/backend/default.c +++ b/src/bookmarks/backend/default.c @@ -128,7 +128,7 @@ read_bookmarks_default(FILE *f) /* Saves the bookmarks to file */ static void write_bookmarks_default(struct secure_save_info *ssi, - struct list_head *bookmarks_list) + LIST_OF(struct bookmark) *bookmarks_list) { int folder_state = get_opt_bool("bookmarks.folder_state"); struct bookmark *bm; diff --git a/src/bookmarks/backend/xbel.c b/src/bookmarks/backend/xbel.c index f0fc40555..d78a76842 100644 --- a/src/bookmarks/backend/xbel.c +++ b/src/bookmarks/backend/xbel.c @@ -58,10 +58,10 @@ static unsigned char * filename_bookmarks_xbel(int writing); static int xbeltree_to_bookmarks_list(struct tree_node *root, struct bookmark *current_parent); static void write_bookmarks_list(struct secure_save_info *ssi, - struct list_head *bookmarks_list, + LIST_OF(struct bookmark) *bookmarks_list, int n, int folder_state); static void write_bookmarks_xbel(struct secure_save_info *ssi, - struct list_head *bookmarks_list); + LIST_OF(struct bookmark) *bookmarks_list); /* Element */ struct tree_node { @@ -134,7 +134,7 @@ read_bookmarks_xbel(FILE *f) static void write_bookmarks_xbel(struct secure_save_info *ssi, - struct list_head *bookmarks_list) + LIST_OF(struct bookmarks) *bookmarks_list) { int folder_state = get_opt_bool("bookmarks.folder_state"); /* We check for readok in filename_bookmarks_xbel(). */ @@ -208,7 +208,7 @@ print_xml_entities(struct secure_save_info *ssi, const unsigned char *str) static void write_bookmarks_list(struct secure_save_info *ssi, - struct list_head *bookmarks_list, + LIST_OF(struct bookmark) *bookmarks_list, int n, int folder_state) { struct bookmark *bm; diff --git a/src/bookmarks/bookmarks.c b/src/bookmarks/bookmarks.c index f9e9a45ea..3439d9017 100644 --- a/src/bookmarks/bookmarks.c +++ b/src/bookmarks/bookmarks.c @@ -32,7 +32,7 @@ #include "util/string.h" /* The list of bookmarks */ -INIT_LIST_HEAD(bookmarks); +INIT_LIST_OF(struct bookmark, bookmarks); /* Set to 1, if bookmarks have changed. */ static int bookmarks_dirty = 0; @@ -147,8 +147,8 @@ init_bookmarks(struct module *module) /* Clears the bookmark list */ static void -free_bookmarks(struct list_head *bookmarks_list, - struct list_head *box_items) +free_bookmarks(LIST_OF(struct bookmark) *bookmarks_list, + LIST_OF(struct listbox_item) *box_items) { struct bookmark *bm; @@ -441,7 +441,7 @@ struct bookmark * get_bookmark_by_name(struct bookmark *folder, unsigned char *title) { struct bookmark *bookmark; - struct list_head *lh; + LIST_OF(struct bookmark) *lh; lh = folder ? &folder->child : &bookmarks; diff --git a/src/bookmarks/bookmarks.h b/src/bookmarks/bookmarks.h index b2e639eeb..84fcc73f4 100644 --- a/src/bookmarks/bookmarks.h +++ b/src/bookmarks/bookmarks.h @@ -20,7 +20,7 @@ struct bookmark { unsigned char *title; /* title of bookmark */ unsigned char *url; /* Location of bookmarked item */ - struct list_head child; + LIST_OF(struct bookmark) child; }; /* Bookmark lists */ diff --git a/src/bookmarks/dialogs.c b/src/bookmarks/dialogs.c index 1b020dcaa..662110891 100644 --- a/src/bookmarks/dialogs.c +++ b/src/bookmarks/dialogs.c @@ -344,7 +344,7 @@ enum move_bookmark_flags { * _into_ dest or, if insert_as_child is 0, _after_ dest. */ static enum move_bookmark_flags do_move_bookmark(struct bookmark *dest, int insert_as_child, - struct list_head *src, struct listbox_data *box) + LIST_OF(struct bookmark) *src, struct listbox_data *box) { static int move_bookmark_event_id = EVENT_NONE; struct bookmark *bm, *next; diff --git a/src/cache/cache.c b/src/cache/cache.c index dc7465751..db9efe1ec 100644 --- a/src/cache/cache.c +++ b/src/cache/cache.c @@ -24,7 +24,7 @@ #include "util/time.h" /* The list of cache entries */ -static INIT_LIST_HEAD(cache_entries); +static INIT_LIST_OF(struct cache_entry, cache_entries); static unsigned longlong cache_size; static int id_counter = 1; diff --git a/src/config/cmdline.c b/src/config/cmdline.c index 179883ae0..27eb83b8f 100644 --- a/src/config/cmdline.c +++ b/src/config/cmdline.c @@ -45,7 +45,7 @@ static unsigned char *remote_url; static enum retval parse_options_(int argc, unsigned char *argv[], struct option *opt, - struct list_head *url_list) + LIST_OF(struct string_list_item) *url_list) { while (argc) { argv++, argc--; @@ -116,7 +116,8 @@ unknown_option: } enum retval -parse_options(int argc, unsigned char *argv[], struct list_head *url_list) +parse_options(int argc, unsigned char *argv[], + LIST_OF(struct string_list_item) *url_list) { return parse_options_(argc, argv, cmdline_options, url_list); } diff --git a/src/config/cmdline.h b/src/config/cmdline.h index cb0853530..4ed390421 100644 --- a/src/config/cmdline.h +++ b/src/config/cmdline.h @@ -4,6 +4,7 @@ #include "main/main.h" #include "util/lists.h" -enum retval parse_options(int, unsigned char *[], struct list_head *); +enum retval parse_options(int, unsigned char *[], + LIST_OF(struct string_list_item) *); #endif diff --git a/src/config/options.c b/src/config/options.c index 43d224461..025c9def3 100644 --- a/src/config/options.c +++ b/src/config/options.c @@ -52,7 +52,7 @@ * (struct option *) instead. This applies to bookmarks, global history and * listbox items as well, though. --pasky */ -static INIT_LIST_HEAD(options_root_tree); +static INIT_LIST_OF(struct option, options_root_tree); static struct option options_root = INIT_OPTION( /* name: */ "", @@ -68,7 +68,7 @@ struct option *config_options; struct option *cmdline_options; static void add_opt_rec(struct option *, unsigned char *, struct option *); -static void free_options_tree(struct list_head *, int recursive); +static void free_options_tree(LIST_OF(struct option) *, int recursive); #ifdef CONFIG_DEBUG /* Detect ending '.' (and some others) in options captions. @@ -305,8 +305,8 @@ get_opt_( static void add_opt_sort(struct option *tree, struct option *option, int abi) { - struct list_head *cat = tree->value.tree; - struct list_head *bcat = &tree->box_item->child; + LIST_OF(struct option) *cat = tree->value.tree; + LIST_OF(struct listbox_item) *bcat = &tree->box_item->child; struct option *pos; /* The list is empty, just add it there. */ @@ -477,7 +477,7 @@ add_opt(struct option *tree, unsigned char *path, unsigned char *capt, mem_free(option); return NULL; } - option->value.tree = (struct list_head *) value; + option->value.tree = (LIST_OF(struct option) *) value; break; case OPT_STRING: if (!value) { @@ -642,10 +642,10 @@ copy_option(struct option *template) return option; } -struct list_head * +LIST_OF(struct option) * init_options_tree(void) { - struct list_head *ptr = mem_alloc(sizeof(*ptr)); + LIST_OF(struct option) *ptr = mem_alloc(sizeof(*ptr)); if (ptr) init_list(*ptr); return ptr; @@ -700,7 +700,7 @@ init_options(void) } static void -free_options_tree(struct list_head *tree, int recursive) +free_options_tree(LIST_OF(struct option) *tree, int recursive) { while (!list_empty(*tree)) delete_option_do(tree->next, recursive); @@ -730,7 +730,7 @@ register_change_hooks(const struct change_hook_info *change_hooks) } void -unmark_options_tree(struct list_head *tree) +unmark_options_tree(LIST_OF(struct option) *tree) { struct option *option; @@ -742,7 +742,7 @@ unmark_options_tree(struct list_head *tree) } void -watermark_deleted_options(struct list_head *tree) +watermark_deleted_options(LIST_OF(struct option) *tree) { struct option *option; @@ -755,7 +755,7 @@ watermark_deleted_options(struct list_head *tree) } static int -check_nonempty_tree(struct list_head *options) +check_nonempty_tree(LIST_OF(struct option) *options) { struct option *opt; @@ -773,7 +773,8 @@ check_nonempty_tree(struct list_head *options) void smart_config_string(struct string *str, int print_comment, int i18n, - struct list_head *options, unsigned char *path, int depth, + LIST_OF(struct option) *options, + unsigned char *path, int depth, void (*fn)(struct string *, struct option *, unsigned char *, int, int, int, int)) { @@ -917,7 +918,7 @@ change_hook_ui(struct session *ses, struct option *current, struct option *chang /* Bit 2 of show means we should always set visibility, otherwise we set it * only on templates. */ static void -update_visibility(struct list_head *tree, int show) +update_visibility(LIST_OF(struct option) *tree, int show) { struct option *opt; diff --git a/src/config/options.h b/src/config/options.h index 54cea42f0..15d9d7949 100644 --- a/src/config/options.h +++ b/src/config/options.h @@ -142,7 +142,7 @@ struct option { }; #define INIT_OPTION(name, flags, type, min, max, value, desc, capt) \ - { NULL_LIST_HEAD, INIT_OBJECT("option"), name, flags, type, min, max, { (struct list_head *) (value) }, desc, capt } + { NULL_LIST_HEAD, INIT_OBJECT("option"), name, flags, type, min, max, { (LIST_OF(struct option) *) (value) }, desc, capt } extern struct option *config_options; extern struct option *cmdline_options; @@ -160,12 +160,14 @@ struct change_hook_info { extern void register_change_hooks(const struct change_hook_info *change_hooks); -extern struct list_head *init_options_tree(void); -extern void unmark_options_tree(struct list_head *); -void watermark_deleted_options(struct list_head *); +extern LIST_OF(struct option) *init_options_tree(void); +extern void unmark_options_tree(LIST_OF(struct option) *); +void watermark_deleted_options(LIST_OF(struct option) *); -extern void smart_config_string(struct string *, int, int, struct list_head *, unsigned char *, int, - void (*)(struct string *, struct option *, unsigned char *, int, int, int, int)); +extern void smart_config_string(struct string *, int, int, + LIST_OF(struct option) *, unsigned char *, int, + void (*)(struct string *, struct option *, + unsigned char *, int, int, int, int)); extern struct option *copy_option(struct option *); extern void delete_option(struct option *); diff --git a/src/config/opttypes.c b/src/config/opttypes.c index bc29b225d..3a5c8915d 100644 --- a/src/config/opttypes.c +++ b/src/config/opttypes.c @@ -368,8 +368,8 @@ color_wr(struct option *opt, struct string *str) static void tree_dup(struct option *opt, struct option *template) { - struct list_head *new = init_options_tree(); - struct list_head *tree = template->value.tree; + LIST_OF(struct option) *new = init_options_tree(); + LIST_OF(struct option) *tree = template->value.tree; struct option *option; if (!new) return; diff --git a/src/cookies/cookies.c b/src/cookies/cookies.c index 30269df78..639e8a605 100644 --- a/src/cookies/cookies.c +++ b/src/cookies/cookies.c @@ -51,7 +51,7 @@ static int cookies_nosave = 0; -static INIT_LIST_HEAD(cookies); +static INIT_LIST_OF(struct cookie, cookies); struct c_domain { LIST_HEAD(struct c_domain); @@ -64,11 +64,10 @@ struct c_domain { * struct c_domain. No other data structures have pointers to these * objects. Currently the domains remain in the list until * @done_cookies clears the whole list. */ -static INIT_LIST_HEAD(c_domains); +static INIT_LIST_OF(struct c_domain, c_domains); -/* List of servers for which there are cookies. Each element is a - * struct cookie_server. */ -static INIT_LIST_HEAD(cookie_servers); +/* List of servers for which there are cookies. */ +static INIT_LIST_OF(struct cookie_server, cookie_servers); /* Only @set_cookies_dirty may make this nonzero. */ static int cookies_dirty = 0; @@ -908,7 +907,7 @@ init_cookies(struct module *module) /* Like @delete_cookie, this function does not set @cookies_dirty. * The caller must do that if appropriate. */ static void -free_cookies_list(struct list_head *list) +free_cookies_list(LIST_OF(struct cookie) *list) { while (!list_empty(*list)) { struct cookie *cookie = list->next; diff --git a/src/cookies/dialogs.c b/src/cookies/dialogs.c index f4df50c82..696cad591 100644 --- a/src/cookies/dialogs.c +++ b/src/cookies/dialogs.c @@ -25,7 +25,7 @@ #include "util/string.h" -INIT_LIST_HEAD(cookie_queries); +INIT_LIST_OF(struct cookie, cookie_queries); static void add_cookie_info_to_string(struct string *string, struct cookie *cookie, diff --git a/src/cookies/dialogs.h b/src/cookies/dialogs.h index a7b6c214e..8896d3f16 100644 --- a/src/cookies/dialogs.h +++ b/src/cookies/dialogs.h @@ -6,7 +6,7 @@ #include "terminal/terminal.h" #include "util/lists.h" -extern struct list_head cookie_queries; +extern LIST_OF(struct cookie) cookie_queries; void accept_cookie_dialog(struct session *ses, void *data); extern struct hierbox_browser cookie_browser; diff --git a/src/dialogs/menu.c b/src/dialogs/menu.c index 172965ca2..744a4b788 100644 --- a/src/dialogs/menu.c +++ b/src/dialogs/menu.c @@ -812,7 +812,7 @@ enum frame_event_status pass_uri_to_command(struct session *ses, struct document_view *doc_view, int which_type) { - struct list_head *tree = get_opt_tree("document.uri_passing"); + LIST_OF(struct option) *tree = get_opt_tree("document.uri_passing"); enum pass_uri_type type = which_type; struct menu_item *items; struct option *option; @@ -887,7 +887,7 @@ void add_uri_command_to_menu(struct menu_item **mi, enum pass_uri_type type, unsigned char *text) { - struct list_head *tree = get_opt_tree("document.uri_passing"); + LIST_OF(struct option) *tree = get_opt_tree("document.uri_passing"); struct option *option; int commands = 0; enum menu_item_flags flags = NO_FLAG; diff --git a/src/document/css/apply.c b/src/document/css/apply.c index c3b9fd748..7e3045b62 100644 --- a/src/document/css/apply.c +++ b/src/document/css/apply.c @@ -117,7 +117,8 @@ static css_applier_T css_appliers[CSS_PT_LAST] = { static void examine_element(struct html_context *html_context, struct css_selector *base, enum css_selector_type seltype, enum css_selector_relation rel, - struct list_head *selectors, struct html_element *element) + LIST_OF(struct css_selector) *selectors, + struct html_element *element) { struct css_selector *selector; @@ -141,7 +142,7 @@ examine_element(struct html_context *html_context, struct css_selector *base, dbginfo(sel, type, base); \ merge_css_selectors(base, sel); \ /* Ancestor matches? */ \ - if ((struct list_head *) element->next \ + if ((LIST_OF(struct html_element) *) element->next \ != &html_context->stack) { \ struct html_element *ancestor; \ /* This is less effective than doing reverse iterations, @@ -151,7 +152,7 @@ examine_element(struct html_context *html_context, struct css_selector *base, * have to duplicate the whole examine_element(), so if * profiles won't show it really costs... */ \ for (ancestor = element->next; \ - (struct list_head *) ancestor \ + (LIST_OF(struct html_element) *) ancestor \ != &html_context->stack;\ ancestor = ancestor->next) \ examine_element(html_context, base, \ @@ -220,7 +221,7 @@ struct css_selector * get_css_selector_for_element(struct html_context *html_context, struct html_element *element, struct css_stylesheet *css, - struct list_head *html_stack) + LIST_OF(struct html_element) *html_stack) { unsigned char *code; struct css_selector *selector; @@ -280,7 +281,7 @@ apply_css_selector_style(struct html_context *html_context, void css_apply(struct html_context *html_context, struct html_element *element, - struct css_stylesheet *css, struct list_head *html_stack) + struct css_stylesheet *css, LIST_OF(struct html_element) *html_stack) { struct css_selector *selector; diff --git a/src/document/css/apply.h b/src/document/css/apply.h index 61423152e..33bccb45a 100644 --- a/src/document/css/apply.h +++ b/src/document/css/apply.h @@ -17,7 +17,7 @@ struct css_selector * get_css_selector_for_element(struct html_context *html_context, struct html_element *element, struct css_stylesheet *css, - struct list_head *html_stack); + LIST_OF(struct html_element) *html_stack); /* Apply properties from an existing selector. */ @@ -30,6 +30,7 @@ apply_css_selector_style(struct html_context *html_context, * attributes (if it contains such an attribute). */ void css_apply(struct html_context *html_context, struct html_element *element, - struct css_stylesheet *css, struct list_head *html_stack); + struct css_stylesheet *css, + LIST_OF(struct html_element) *html_stack); #endif diff --git a/src/document/css/parser.c b/src/document/css/parser.c index 2aca47539..78838371f 100644 --- a/src/document/css/parser.c +++ b/src/document/css/parser.c @@ -23,7 +23,8 @@ void -css_parse_properties(struct list_head *props, struct scanner *scanner) +css_parse_properties(LIST_OF(struct css_property) *props, + struct scanner *scanner) { assert(props && scanner); @@ -195,7 +196,8 @@ struct selector_pkg { * * @returns @a selector or the one into which it was merged. */ static struct css_selector * -reparent_selector(struct list_head *sels, struct css_selector *selector, +reparent_selector(LIST_OF(struct css_selector) *sels, + struct css_selector *selector, struct css_selector **watch) { struct css_selector *twin = find_css_selector(sels, selector->type, @@ -230,7 +232,7 @@ reparent_selector(struct list_head *sels, struct css_selector *selector, */ static void css_parse_selector(struct css_stylesheet *css, struct scanner *scanner, - struct list_head *selectors) + LIST_OF(struct selector_pkg) *selectors) { /* Shell for the last selector (the whole selector chain, that is). */ struct selector_pkg *pkg = NULL; @@ -470,8 +472,8 @@ css_parse_selector(struct css_stylesheet *css, struct scanner *scanner, static void css_parse_ruleset(struct css_stylesheet *css, struct scanner *scanner) { - INIT_LIST_HEAD(selectors); - INIT_LIST_HEAD(properties); + INIT_LIST_OF(struct selector_pkg, selectors); + INIT_LIST_OF(struct css_property, properties); struct selector_pkg *pkg; css_parse_selector(css, scanner, &selectors); diff --git a/src/document/css/parser.h b/src/document/css/parser.h index e9003f420..be39afbab 100644 --- a/src/document/css/parser.h +++ b/src/document/css/parser.h @@ -15,7 +15,8 @@ struct uri; * css_property}es to the specified list. The function returns positive value * in case it recognized a property in the given string, or zero in case of an * error. */ -void css_parse_properties(struct list_head *props, struct scanner *scanner); +void css_parse_properties(LIST_OF(struct css_property) *props, + struct scanner *scanner); /* Parses the @string and adds any recognized selectors + properties to the diff --git a/src/document/css/stylesheet.c b/src/document/css/stylesheet.c index a590f28db..63303ba1f 100644 --- a/src/document/css/stylesheet.c +++ b/src/document/css/stylesheet.c @@ -25,7 +25,8 @@ struct css_selector * -find_css_selector(struct list_head *sels, enum css_selector_type type, +find_css_selector(LIST_OF(struct css_selector) *sels, + enum css_selector_type type, enum css_selector_relation rel, const unsigned char *name, int namelen) { @@ -45,7 +46,8 @@ find_css_selector(struct list_head *sels, enum css_selector_type type, } struct css_selector * -init_css_selector(struct list_head *sels, enum css_selector_type type, +init_css_selector(LIST_OF(struct css_selector) *sels, + enum css_selector_type type, unsigned char *name, int namelen) { struct css_selector *selector; @@ -78,7 +80,8 @@ init_css_selector(struct list_head *sels, enum css_selector_type type, } struct css_selector * -get_css_selector(struct list_head *sels, enum css_selector_type type, +get_css_selector(LIST_OF(struct css_selector) *sels, + enum css_selector_type type, enum css_selector_relation rel, unsigned char *name, int namelen) { @@ -127,7 +130,7 @@ add_selector_property(struct css_selector *selector, struct css_property *prop) void add_selector_properties(struct css_selector *selector, - struct list_head *properties) + LIST_OF(struct css_property) *properties) { struct css_property *prop; @@ -185,7 +188,7 @@ done_css_selector(struct css_selector *selector) #ifdef DEBUG_CSS void -dump_css_selector_tree_iter(struct list_head *sels, int level) +dump_css_selector_tree_iter(LIST_OF(struct css_selector) *sels, int level) { struct css_selector *sel; @@ -204,7 +207,7 @@ dump_css_selector_tree_iter(struct list_head *sels, int level) } void -dump_css_selector_tree(struct list_head *sels) +dump_css_selector_tree(LIST_OF(struct css_selector) *sels) { dump_css_selector_tree_iter(sels, 0); } diff --git a/src/document/css/stylesheet.h b/src/document/css/stylesheet.h index 98d8eac1a..046339350 100644 --- a/src/document/css/stylesheet.h +++ b/src/document/css/stylesheet.h @@ -106,7 +106,7 @@ void done_css_stylesheet(struct css_stylesheet *css); /* Returns a new freshly made selector adding it to the given selector * list, or NULL. */ -struct css_selector *get_css_selector(struct list_head *selector_list, +struct css_selector *get_css_selector(LIST_OF(struct css_selector) *selector_list, enum css_selector_type type, enum css_selector_relation rel, unsigned char *name, int namelen); @@ -117,7 +117,7 @@ struct css_selector *get_css_selector(struct list_head *selector_list, /* Looks up the selector of the name @name and length @namelen in the * given list of selectors. */ -struct css_selector *find_css_selector(struct list_head *selector_list, +struct css_selector *find_css_selector(LIST_OF(struct css_selector) *selector_list, enum css_selector_type type, enum css_selector_relation rel, const unsigned char *name, int namelen); @@ -127,13 +127,13 @@ struct css_selector *find_css_selector(struct list_head *selector_list, /* Initialize the selector structure. This is a rather low-level function from * your POV. */ -struct css_selector *init_css_selector(struct list_head *selector_list, +struct css_selector *init_css_selector(LIST_OF(struct css_selector) *selector_list, enum css_selector_type type, unsigned char *name, int namelen); /* Add all properties from the list to the given @selector. */ void add_selector_properties(struct css_selector *selector, - struct list_head *properties); + LIST_OF(struct css_property) *properties); /* Join @sel2 to @sel1, @sel1 taking precedence in all conflicts. */ void merge_css_selectors(struct css_selector *sel1, struct css_selector *sel2); @@ -143,7 +143,7 @@ void done_css_selector(struct css_selector *selector); #ifdef DEBUG_CSS /* Dumps the selector tree to stderr. */ -void dump_css_selector_tree(struct list_head *selector_list); +void dump_css_selector_tree(LIST_OF(struct css_selector) *selector_list); #endif #endif diff --git a/src/document/document.c b/src/document/document.c index 3586f2b36..67ab75f5d 100644 --- a/src/document/document.c +++ b/src/document/document.c @@ -33,7 +33,7 @@ #include "viewer/text/link.h" -static INIT_LIST_HEAD(format_cache); +static INIT_LIST_OF(struct document, format_cache); struct document * init_document(struct cache_entry *cached, struct document_options *options) diff --git a/src/document/html/internal.h b/src/document/html/internal.h index 419da38fd..c656660fe 100644 --- a/src/document/html/internal.h +++ b/src/document/html/internal.h @@ -59,7 +59,7 @@ struct html_context { * html/parser/parse.c * html/parser/stack.c * html/parser.c */ - struct list_head stack; + LIST_OF(struct html_element) stack; /* For parser/parse.c: */ unsigned char *eoff; /* For parser/forms.c too */ diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 0a08feec5..c59a34336 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -1869,7 +1869,7 @@ void check_html_form_hierarchy(struct part *part) { struct document *document = part->document; - INIT_LIST_HEAD(form_controls); + INIT_LIST_OF(struct form_control, form_controls); struct form *form; struct form_control *fc, *next; diff --git a/src/document/renderer.c b/src/document/renderer.c index 1a464c936..03e5938db 100644 --- a/src/document/renderer.c +++ b/src/document/renderer.c @@ -53,7 +53,8 @@ * But I want to take no risk by reworking that now. --pasky */ static void add_snippets(struct ecmascript_interpreter *interpreter, - struct list_head *doc_snippets, struct list_head *queued_snippets) + LIST_OF(struct string_list_item) *doc_snippets, + LIST_OF(struct string_list_item) *queued_snippets) { struct string_list_item *doc_current = doc_snippets->next; @@ -112,7 +113,8 @@ add_snippets(struct ecmascript_interpreter *interpreter, static void process_snippets(struct ecmascript_interpreter *interpreter, - struct list_head *snippets, struct string_list_item **current) + LIST_OF(struct string_list_item) *snippets, + struct string_list_item **current) { if (!*current) *current = snippets->next; diff --git a/src/formhist/formhist.c b/src/formhist/formhist.c index 822ce4920..469dcdf50 100644 --- a/src/formhist/formhist.c +++ b/src/formhist/formhist.c @@ -42,7 +42,7 @@ static struct option_info forms_history_options[] = { NULL_OPTION_INFO, }; -INIT_LIST_HEAD(saved_forms); +INIT_LIST_OF(struct formhist_data, saved_forms); static struct formhist_data * new_formhist_item(unsigned char *url) @@ -386,7 +386,7 @@ get_form_history_value(unsigned char *url, unsigned char *name) } void -memorize_form(struct session *ses, struct list_head *submit, +memorize_form(struct session *ses, LIST_OF(struct submitted_value) *submit, struct form *forminfo) { /* [gettext_accelerator_context(memorize_form)] */ diff --git a/src/formhist/formhist.h b/src/formhist/formhist.h index 3be6622d4..7dcd7adc7 100644 --- a/src/formhist/formhist.h +++ b/src/formhist/formhist.h @@ -11,7 +11,7 @@ struct formhist_data { OBJECT_HEAD(struct formhist_data); /* List of submitted_values for this form */ - struct list_head *submit; + LIST_OF(struct submitted_value) *submit; struct listbox_item *box_item; @@ -26,7 +26,9 @@ struct formhist_data { * value if present, NULL upon an error. */ unsigned char *get_form_history_value(unsigned char *url, unsigned char *name); -void memorize_form(struct session *ses, struct list_head *submit, struct form *forminfo); +void memorize_form(struct session *ses, + LIST_OF(struct submitted_value) *submit, + struct form *forminfo); int save_formhist_to_file(void); void delete_formhist_item(struct formhist_data *form); diff --git a/src/globhist/globhist.c b/src/globhist/globhist.c index 4eab05b5f..7f1d7b2be 100644 --- a/src/globhist/globhist.c +++ b/src/globhist/globhist.c @@ -39,7 +39,7 @@ INIT_INPUT_HISTORY(global_history); -INIT_LIST_HEAD(global_history_reap_list); +INIT_LIST_OF(struct global_history_item, global_history_reap_list); /* GUI stuff. Declared here because done_global_history() frees it. */ diff --git a/src/main/main.c b/src/main/main.c index 1dec85c13..1894e575d 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -73,7 +73,7 @@ static int init_b = 0; /* Check if either stdin or stdout are pipes */ static void -check_stdio(struct list_head *url_list) +check_stdio(LIST_OF(struct string_list_item) *url_list) { assert(!remote_session_flags); @@ -174,7 +174,7 @@ done_ipc(void) static void init(void) { - INIT_LIST_HEAD(url_list); + INIT_LIST_OF(struct string_list_item, url_list); int fd = -1; enum retval ret; diff --git a/src/main/select.c b/src/main/select.c index a69e4d20f..c65c4a5cd 100644 --- a/src/main/select.c +++ b/src/main/select.c @@ -90,7 +90,7 @@ struct bottom_half { void *data; }; -static INIT_LIST_HEAD(bottom_halves); +static INIT_LIST_OF(struct bottom_half, bottom_halves); int register_bottom_half_do(select_handler_T fn, void *data) diff --git a/src/main/timer.c b/src/main/timer.c index 1a362cd2d..33b007370 100644 --- a/src/main/timer.c +++ b/src/main/timer.c @@ -24,7 +24,7 @@ struct timer { /* @timers.next points to the timer with the smallest interval, * @timers.next->next to the second smallest, and so on. */ -static INIT_LIST_HEAD(timers); +static INIT_LIST_OF(struct timer, timers); int get_timers_count(void) diff --git a/src/mime/dialogs.c b/src/mime/dialogs.c index 1d56e45e6..f140c9d47 100644 --- a/src/mime/dialogs.c +++ b/src/mime/dialogs.c @@ -146,7 +146,7 @@ void menu_list_ext(struct terminal *term, void *fn_, void *xxx) { menu_func_T fn = fn_; - struct list_head *opt_tree = get_opt_tree("mime.extension"); + LIST_OF(struct option) *opt_tree = get_opt_tree("mime.extension"); struct option *opt; struct menu_item *mi = NULL; diff --git a/src/network/connection.c b/src/network/connection.c index f49cf01f4..ece33adca 100644 --- a/src/network/connection.c +++ b/src/network/connection.c @@ -59,9 +59,9 @@ static unsigned int connection_id = 0; static int active_connections = 0; static timer_id_T keepalive_timeout = TIMER_ID_UNDEF; -static INIT_LIST_HEAD(connection_queue); -static INIT_LIST_HEAD(host_connections); -static INIT_LIST_HEAD(keepalive_connections); +static INIT_LIST_OF(struct connection, connection_queue); +static INIT_LIST_OF(struct host_connection, host_connections); +static INIT_LIST_OF(struct keepalive_connection, keepalive_connections); /* Prototypes */ static void notify_connection_callbacks(struct connection *conn); diff --git a/src/network/connection.h b/src/network/connection.h index c4a4b2e4d..61931e192 100644 --- a/src/network/connection.h +++ b/src/network/connection.h @@ -16,7 +16,7 @@ struct uri; struct connection { LIST_HEAD(struct connection); - struct list_head downloads; + LIST_OF(struct download) downloads; struct progress *progress; /* If no proxy is used uri and proxied_uri are the same. */ @@ -82,7 +82,7 @@ struct popen_data { unsigned char *filename; }; -extern struct list_head copiousoutput_data; +extern LIST_OF(struct popen_data) copiousoutput_data; int register_check_queue(void); diff --git a/src/network/dns.c b/src/network/dns.c index 29a3717e9..73458fe2d 100644 --- a/src/network/dns.c +++ b/src/network/dns.c @@ -76,7 +76,7 @@ struct dnsquery { static struct dnsquery *dns_queue = NULL; #endif -static INIT_LIST_HEAD(dns_cache); +static INIT_LIST_OF(struct dnsentry, dns_cache); static void done_dns_lookup(struct dnsquery *query, enum dns_result res); diff --git a/src/network/state.c b/src/network/state.c index 5b0f5a21a..e4588d326 100644 --- a/src/network/state.c +++ b/src/network/state.c @@ -136,7 +136,7 @@ struct strerror_val { unsigned char msg[1]; /* must be last */ }; -static INIT_LIST_HEAD(strerror_buf); /* struct strerror_val */ +static INIT_LIST_OF(struct strerror_val, strerror_buf); /* It returns convenient error message, depending on @state. * It never returns NULL (if one changes that, be warn that diff --git a/src/osdep/beos/beos.c b/src/osdep/beos/beos.c index 2f22138f3..79edef6ad 100644 --- a/src/osdep/beos/beos.c +++ b/src/osdep/beos/beos.c @@ -61,7 +61,7 @@ struct active_thread { void *data; }; -INIT_LIST_HEAD(active_threads); +INIT_LIST_OF(struct active_thread, active_threads); int32 started_thr(void *data) @@ -114,12 +114,14 @@ rel: void terminate_osdep(void) { - struct list_head *p; + LIST_OF(struct active_thread) *p; struct active_thread *thrd; if (acquire_sem(thr_sem) < B_NO_ERROR) return; foreach (thrd, active_threads) kill_thread(thrd->tid); + /* Cannot use free_list(active_threads) because it would call + * mem_free(p) and we need free(p). */ while ((p = active_threads.next) != &active_threads) { del_from_list(p); free(p); diff --git a/src/protocol/auth/auth.c b/src/protocol/auth/auth.c index 4f18db5d1..dc1c1643f 100644 --- a/src/protocol/auth/auth.c +++ b/src/protocol/auth/auth.c @@ -26,7 +26,7 @@ #define DEBUG_HTTP_AUTH #endif -static INIT_LIST_HEAD(auth_entry_list); +static INIT_LIST_OF(struct auth_entry, auth_entry_list); /* Find if url/realm is in auth list. If a matching url is found, but realm is diff --git a/src/protocol/bittorrent/bittorrent.c b/src/protocol/bittorrent/bittorrent.c index f0847b03e..9ce12b92e 100644 --- a/src/protocol/bittorrent/bittorrent.c +++ b/src/protocol/bittorrent/bittorrent.c @@ -228,7 +228,7 @@ get_bittorrent_peerwire_max_request_length(void) /* File selection store. */ -static INIT_LIST_HEAD(bittorrent_selections); +static INIT_LIST_OF(struct bittorrent_selection_info, bittorrent_selections); struct bittorrent_selection_info { LIST_HEAD(struct bittorrent_selection_info); @@ -291,7 +291,7 @@ add_bittorrent_selection(struct uri *uri, int *selection, size_t size) /* Message queue. */ -static INIT_LIST_HEAD(bittorrent_messages); +static INIT_LIST_OF(struct bittorrent_message, bittorrent_messages); void add_bittorrent_message(struct uri *uri, enum connection_state state, diff --git a/src/protocol/bittorrent/common.c b/src/protocol/bittorrent/common.c index 11d8555de..51213c3da 100644 --- a/src/protocol/bittorrent/common.c +++ b/src/protocol/bittorrent/common.c @@ -463,7 +463,7 @@ struct bittorrent_blacklist_item { bittorrent_id_T id; }; -static INIT_LIST_HEAD(bittorrent_blacklist); +static INIT_LIST_OF(struct bittorrent_blacklist_item, bittorrent_blacklist); static struct bittorrent_blacklist_item * diff --git a/src/protocol/bittorrent/peerconnect.c b/src/protocol/bittorrent/peerconnect.c index ddb80375d..ba93982cc 100644 --- a/src/protocol/bittorrent/peerconnect.c +++ b/src/protocol/bittorrent/peerconnect.c @@ -43,12 +43,12 @@ static int bittorrent_socket = -1; /* The active BitTorrent connections sharing the above listening port. */ -static INIT_LIST_HEAD(bittorrent_connections); +static INIT_LIST_OF(struct bittorrent_connection, bittorrent_connections); /* The incoming (and pending anonymous) peer connections which has not yet been * assigned to a BitTorrent connection because the info hash has not been read * from the handshake. */ -static INIT_LIST_HEAD(bittorrent_peer_connections); +static INIT_LIST_OF(struct bittorrent_peer_connection, bittorrent_peer_connections); /* Loop the bittorrent connection list and return matching connection diff --git a/src/protocol/bittorrent/piececache.c b/src/protocol/bittorrent/piececache.c index 80b54d99e..c7f4eac72 100644 --- a/src/protocol/bittorrent/piececache.c +++ b/src/protocol/bittorrent/piececache.c @@ -341,7 +341,7 @@ add_piece_to_bittorrent_free_list(struct bittorrent_piece_cache *cache, { struct bittorrent_peer_request *request, *next; uint32_t request_length, piece_length, piece_offset; - INIT_LIST_HEAD(requests); + INIT_LIST_OF(struct bittorrent_peer_request, requests); uint16_t blocks = 0; assert(piece <= bittorrent->meta.pieces); diff --git a/src/protocol/http/blacklist.c b/src/protocol/http/blacklist.c index ea1e34cc3..8f92d9eac 100644 --- a/src/protocol/http/blacklist.c +++ b/src/protocol/http/blacklist.c @@ -22,7 +22,7 @@ struct blacklist_entry { unsigned char host[1]; /* Must be last. */ }; -static INIT_LIST_HEAD(blacklist); +static INIT_LIST_OF(struct blacklist_entry, blacklist); static struct blacklist_entry * diff --git a/src/protocol/http/http_negotiate.c b/src/protocol/http/http_negotiate.c index f9a144e40..470b07179 100644 --- a/src/protocol/http/http_negotiate.c +++ b/src/protocol/http/http_negotiate.c @@ -44,7 +44,7 @@ struct negotiate { gss_buffer_desc input_token; }; -static INIT_LIST_HEAD(negotiate_list); +static INIT_LIST_OF(struct negotiate, negotiate_list); static struct negotiate * http_negotiate_get(struct uri *uri, int *isnew, int alloc) diff --git a/src/session/download.c b/src/session/download.c index cdeb3b9cb..a019e6c9f 100644 --- a/src/session/download.c +++ b/src/session/download.c @@ -62,9 +62,9 @@ /* TODO: tp_*() should be in separate file, I guess? --pasky */ -INIT_LIST_HEAD(downloads); +INIT_LIST_OF(struct file_download, downloads); -INIT_LIST_HEAD(copiousoutput_data); +INIT_LIST_OF(struct popen_data, copiousoutput_data); int download_is_progressing(struct download *download) diff --git a/src/session/download.h b/src/session/download.h index 8c80e20bc..e14e0e755 100644 --- a/src/session/download.h +++ b/src/session/download.h @@ -85,7 +85,7 @@ struct file_download { }; /* Stack of all running downloads */ -extern struct list_head downloads; +extern LIST_OF(struct file_download) downloads; static inline int is_in_downloads_list(struct file_download *file_download) diff --git a/src/session/history.c b/src/session/history.c index 8c462e624..bde11e020 100644 --- a/src/session/history.c +++ b/src/session/history.c @@ -24,7 +24,7 @@ static inline void -free_history(struct list_head *history) +free_history(LIST_OF(struct location) *history) { while (!list_empty(*history)) { struct location *loc = history->next; diff --git a/src/session/location.h b/src/session/location.h index 9f1631e8d..e135b003b 100644 --- a/src/session/location.h +++ b/src/session/location.h @@ -8,7 +8,7 @@ struct location { LIST_HEAD(struct location); - struct list_head frames; + LIST_OF(struct frame) frames; struct download download; struct view_state vs; }; diff --git a/src/session/session.c b/src/session/session.c index 20f2222a5..19da4e56e 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -85,7 +85,7 @@ struct session_info { #define file_to_load_is_active(ftl) ((ftl)->req_sent && is_in_progress_state((ftl)->download.state)) -INIT_LIST_HEAD(sessions); +INIT_LIST_OF(struct session, sessions); enum remote_session_flags remote_session_flags; @@ -97,7 +97,7 @@ static struct file_to_load *request_additional_file(struct session *, static window_handler_T tabwin_func; -static INIT_LIST_HEAD(session_info); +static INIT_LIST_OF(struct session_info, session_info); static int session_info_id = 1; static struct session_info * @@ -475,7 +475,7 @@ struct questions_entry { void *data; }; -INIT_LIST_HEAD(questions_queue); +INIT_LIST_OF(struct questions_entry, questions_queue); void @@ -976,7 +976,8 @@ init_remote_session(struct session *ses, enum remote_session_flags *remote_ptr, struct string * -encode_session_info(struct string *info, struct list_head *url_list) +encode_session_info(struct string *info, + LIST_OF(struct string_list_item) *url_list) { struct string_list_item *url; diff --git a/src/session/session.h b/src/session/session.h index d9e33dba4..1aac8827a 100644 --- a/src/session/session.h +++ b/src/session/session.h @@ -221,7 +221,8 @@ print_error_dialog(struct session *ses, enum connection_state state, void process_file_requests(struct session *); -struct string *encode_session_info(struct string *info, struct list_head *url_list); +struct string *encode_session_info(struct string *info, + LIST_OF(struct string_list_item) *url_list); /* Returns zero if the info was remote sessions or if it failed to create any * sessions. */ @@ -262,7 +263,7 @@ struct link *get_current_link_in_view(struct document_view *doc_view); unsigned char *get_current_link_url(struct session *, unsigned char *, size_t); unsigned char *get_current_link_name(struct session *, unsigned char *, size_t); -extern struct list_head questions_queue; +extern LIST_OF(struct questions_entry) questions_queue; void add_questions_entry(void (*callback)(struct session *, void *), void *data); void check_questions_queue(struct session *ses); diff --git a/src/terminal/screen.c b/src/terminal/screen.c index c0cc29de9..66acf5471 100644 --- a/src/terminal/screen.c +++ b/src/terminal/screen.c @@ -269,7 +269,7 @@ static const struct screen_driver_opt *const screen_driver_opts[] = { #define use_utf8_io(driver) ((driver)->opt.charsets[0] != -1) -static INIT_LIST_HEAD(active_screen_drivers); +static INIT_LIST_OF(struct screen_driver, active_screen_drivers); /* Set driver->opt according to driver->type and term_spec. * Other members of *driver need not have been initialized. diff --git a/src/terminal/tab.c b/src/terminal/tab.c index 8aaf8a38d..e4dfa63b0 100644 --- a/src/terminal/tab.c +++ b/src/terminal/tab.c @@ -106,7 +106,7 @@ get_tab_by_number(struct terminal *term, int num) /* Ensure that the return value actually points to a struct * window. */ - assertm((struct list_head *) win != &term->windows, + assertm((LIST_OF(struct window) *) win != &term->windows, "tab number out of range"); if_assert_failed return term->windows.next; diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index 90c836c24..9e60e4b8c 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -36,7 +36,7 @@ #include "viewer/text/textarea.h" -INIT_LIST_HEAD(terminals); +INIT_LIST_OF(struct terminal, terminals); static void check_if_no_terminal(void); diff --git a/src/util/lists.h b/src/util/lists.h index 806e5cc5e..094f3ec33 100644 --- a/src/util/lists.h +++ b/src/util/lists.h @@ -115,10 +115,14 @@ struct xlist_head { #endif /* LISTDEBUG */ -#define INIT_LIST_HEAD(x) struct list_head x = { D_LIST_HEAD(x) } +/** Define and initialize a list variable. The @a element_T parameter + * currently serves as documentation only; the compiler does not check + * that it matches. */ +#define INIT_LIST_OF(element_T, x) struct list_head x = { D_LIST_HEAD(x) } /** A list intended to contain elements of a specific type. The - * parameter currently serves as documentation only. Doxyfile defines + * @a element_T parameter currently serves as documentation only; + * the compiler does not check that it matches. Doxyfile defines * this macro differently in order to get better collaboration * diagrams. */ #define LIST_OF(element_T) struct list_head diff --git a/src/util/memdebug.c b/src/util/memdebug.c index 8e8d0f795..9e7a224c6 100644 --- a/src/util/memdebug.c +++ b/src/util/memdebug.c @@ -163,7 +163,7 @@ struct alloc_header { struct mem_stats mem_stats; -INIT_LIST_HEAD(memory_list); +INIT_LIST_OF(struct alloc_header, memory_list); #ifdef LOG_MEMORY_ALLOC static void diff --git a/src/util/string.c b/src/util/string.c index 44e6cd0aa..65fb19352 100644 --- a/src/util/string.c +++ b/src/util/string.c @@ -467,8 +467,8 @@ add_format_to_string(struct string *string, const unsigned char *format, ...) } struct string * -add_to_string_list(struct list_head *list, const unsigned char *source, - int length) +add_to_string_list(LIST_OF(struct string_list_item) *list, + const unsigned char *source, int length) { struct string_list_item *item; struct string *string; @@ -494,7 +494,7 @@ add_to_string_list(struct list_head *list, const unsigned char *source, } void -free_string_list(struct list_head *list) +free_string_list(LIST_OF(struct string_list_item) *list) { assertm(list != NULL, "[free_string_list]"); if_assert_failed return; diff --git a/src/util/string.h b/src/util/string.h index 123cac2b6..b1043a8be 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -250,10 +250,10 @@ struct string_list_item { /* Adds @string with @length chars to the list. If length is -1 it will be set * to the return value of strlen(). */ struct string * -add_to_string_list(struct list_head *list, const unsigned char *string, - int length); +add_to_string_list(LIST_OF(struct string_list_item) *list, + const unsigned char *string, int length); -void free_string_list(struct list_head *list); +void free_string_list(LIST_OF(struct string_list_item) *list); /* Returns an empty C string or @str if different from NULL. */ diff --git a/src/viewer/dump/dump.c b/src/viewer/dump/dump.c index 63b2bf1f5..b89a611c9 100644 --- a/src/viewer/dump/dump.c +++ b/src/viewer/dump/dump.c @@ -301,10 +301,10 @@ terminate: } void -dump_next(struct list_head *url_list) +dump_next(LIST_OF(struct string_list_item) *url_list) { - static INIT_LIST_HEAD(todo_list); - static INIT_LIST_HEAD(done_list); + static INIT_LIST_OF(struct string_list_item, todo_list); + static INIT_LIST_OF(struct string_list_item, done_list); struct string_list_item *item; if (url_list) { diff --git a/src/viewer/dump/dump.h b/src/viewer/dump/dump.h index a814f585f..cf60acfe0 100644 --- a/src/viewer/dump/dump.h +++ b/src/viewer/dump/dump.h @@ -12,6 +12,6 @@ struct string * add_document_to_string(struct string *string, struct document *document); int dump_to_file(struct document *, int); -void dump_next(struct list_head *); +void dump_next(LIST_OF(struct string_list_item) *); #endif diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index e45674a52..a1c8f0a16 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -612,7 +612,7 @@ draw_forms(struct terminal *term, struct document_view *doc_view) void -done_submitted_value_list(struct list_head *list) +done_submitted_value_list(LIST_OF(struct submitted_value) *list) { struct submitted_value *sv, *svtmp; @@ -630,7 +630,7 @@ done_submitted_value_list(struct list_head *list) static void add_submitted_value_to_list(struct form_control *fc, struct form_state *fs, - struct list_head *list) + LIST_OF(struct submitted_value) *list) { struct submitted_value *sub; unsigned char *name; @@ -693,7 +693,7 @@ add_submitted_value_to_list(struct form_control *fc, } static void -sort_submitted_values(struct list_head *list) +sort_submitted_values(LIST_OF(struct submitted_value) *list) { while (1) { struct submitted_value *sub; @@ -725,7 +725,8 @@ sort_submitted_values(struct list_head *list) static void get_successful_controls(struct document_view *doc_view, - struct form_control *fc, struct list_head *list) + struct form_control *fc, + LIST_OF(struct submitted_value) *list) { struct form_control *fc2; @@ -750,7 +751,7 @@ get_successful_controls(struct document_view *doc_view, } static void -encode_controls(struct list_head *l, struct string *data, +encode_controls(LIST_OF(struct submitted_value) *l, struct string *data, int cp_from, int cp_to) { struct submitted_value *sv; @@ -899,7 +900,8 @@ check_boundary(struct string *data, struct boundary_info *boundary) /* FIXME: shouldn't we encode data at send time (in http.c) ? --Zas */ static void -encode_multipart(struct session *ses, struct list_head *l, struct string *data, +encode_multipart(struct session *ses, LIST_OF(struct submitted_value) *l, + struct string *data, struct boundary_info *boundary, int cp_from, int cp_to) { struct conv_table *convert_table = NULL; @@ -1062,7 +1064,7 @@ encode_newlines(struct string *string, unsigned char *data) } static void -encode_text_plain(struct list_head *l, struct string *data, +encode_text_plain(LIST_OF(struct submitted_value) *l, struct string *data, int cp_from, int cp_to) { struct submitted_value *sv; @@ -1142,7 +1144,7 @@ get_form_uri(struct session *ses, struct document_view *doc_view, struct form_control *fc) { struct boundary_info boundary; - INIT_LIST_HEAD(submit); + INIT_LIST_OF(struct submitted_value, submit); struct string data; struct string go; int cp_from, cp_to; diff --git a/src/viewer/text/form.h b/src/viewer/text/form.h index 02e92d1bf..f8c8e466a 100644 --- a/src/viewer/text/form.h +++ b/src/viewer/text/form.h @@ -97,7 +97,7 @@ struct delayed_submit_form { struct submitted_value *init_submitted_value(unsigned char *name, unsigned char *value, enum form_type type, struct form_control *fc, int position); void done_submitted_value(struct submitted_value *sv); -void done_submitted_value_list(struct list_head *list); +void done_submitted_value_list(LIST_OF(struct submitted_value) *list); struct uri *get_form_uri(struct session *ses, struct document_view *doc_view, struct form_control *fc);