From 20c161559c6a45eb7684ce745c512f6802d9d1a2 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 16 Jan 2022 19:09:27 +0100 Subject: [PATCH] [mem_alloc] cast return value --- src/bfu/dialog.c | 2 +- src/bfu/hierbox.c | 2 +- src/bfu/inpfield.c | 2 +- src/bfu/inphist.c | 2 +- src/bfu/msgbox.c | 2 +- src/bookmarks/backend/xbel.c | 4 ++-- src/config/dialogs.c | 4 ++-- src/config/domain.c | 2 +- src/config/options.c | 4 ++-- src/config/options.h | 2 +- src/config/opttypes.c | 4 ++-- src/cookies/cookies.c | 2 +- src/dialogs/document.c | 2 +- src/dialogs/menu.c | 2 +- src/document/css/stylesheet.c | 2 +- src/document/dom/util.c | 2 +- src/document/html/frames.c | 2 +- src/document/html/parser.c | 2 +- src/document/html/parser/link.c | 2 +- src/document/html/parser/parse.c | 2 +- src/document/html/parser/stack.c | 2 +- src/document/html/renderer.c | 12 ++++++------ src/document/html/tables.c | 8 ++++---- src/document/plain/renderer.c | 2 +- src/document/refresh.c | 2 +- src/document/xml/renderer2.c | 2 +- src/document/xml/tables.c | 2 +- src/document/xml/tags.c | 2 +- src/dom/test/sgml-parser.c | 2 +- src/ecmascript/quickjs/heartbeat.c | 2 +- src/ecmascript/spidermonkey/heartbeat.c | 2 +- src/encoding/bzip2.c | 2 +- src/encoding/encoding.c | 2 +- src/encoding/gzip.c | 2 +- src/encoding/lzma.c | 2 +- src/formhist/formhist.c | 2 +- src/intl/charsets.c | 4 ++-- src/intl/gettext/loadmsgcat.c | 4 ++-- src/intl/gettext/localealias.c | 2 +- src/main/select.c | 4 ++-- src/main/timer.c | 4 ++-- src/mime/backend/mailcap.c | 2 +- src/network/dns.c | 2 +- src/network/socket.c | 4 ++-- src/network/ssl/ssl.c | 2 +- src/osdep/os2/os2.c | 6 +++--- src/osdep/osdep.c | 2 +- src/osdep/unix/unix.c | 2 +- src/protocol/bittorrent/common.c | 2 +- src/protocol/bittorrent/peerwire.c | 2 +- src/protocol/bittorrent/piececache.c | 2 +- src/protocol/header.c | 2 +- src/protocol/http/blacklist.c | 2 +- src/protocol/uri.c | 2 +- src/scripting/python/dialogs.c | 2 +- src/scripting/python/load.c | 4 ++-- src/scripting/smjs/action_object.c | 2 +- src/scripting/smjs/load_uri.c | 4 ++-- src/session/session.c | 2 +- src/session/task.c | 2 +- src/terminal/kbd.c | 2 +- src/terminal/screen.c | 2 +- src/terminal/terminal.c | 6 +++--- src/terminal/window.c | 2 +- src/util/base64.c | 4 ++-- src/util/fastfind.c | 2 +- src/util/file.c | 6 +++--- src/util/hash.c | 4 ++-- src/util/memlist.c | 6 +++--- src/util/memory.h | 8 ++++---- src/util/snprintf.c | 2 +- src/util/snprintf.h | 2 +- src/util/string.c | 12 ++++++------ src/viewer/dump/dump.c | 2 +- src/viewer/text/form.c | 2 +- src/viewer/text/search.c | 6 +++--- src/viewer/text/vs.c | 2 +- 77 files changed, 116 insertions(+), 116 deletions(-) diff --git a/src/bfu/dialog.c b/src/bfu/dialog.c index 9045ec1a..8770863b 100644 --- a/src/bfu/dialog.c +++ b/src/bfu/dialog.c @@ -159,7 +159,7 @@ init_widget(struct dialog_data *dlg_data, int i) widget_data->widget = &dlg_data->dlg->widgets[i]; if (widget_data->widget->datalen) { - widget_data->cdata = mem_alloc(widget_data->widget->datalen); + widget_data->cdata = (char *)mem_alloc(widget_data->widget->datalen); if (!widget_data->cdata) { return NULL; } diff --git a/src/bfu/hierbox.c b/src/bfu/hierbox.c index c81e6f76..fbca16f0 100644 --- a/src/bfu/hierbox.c +++ b/src/bfu/hierbox.c @@ -219,7 +219,7 @@ hierbox_ev_init(struct dialog_data *dlg_data) /* If we fail here it only means automatic updating * will not be possible so no need to panic. */ - item = mem_alloc(sizeof(*item)); + item = (struct hierbox_dialog_list_item *)mem_alloc(sizeof(*item)); if (item) { item->dlg_data = dlg_data; add_to_list(browser->dialogs, item); diff --git a/src/bfu/inpfield.c b/src/bfu/inpfield.c index fe1e60b4..6645dc21 100644 --- a/src/bfu/inpfield.c +++ b/src/bfu/inpfield.c @@ -365,7 +365,7 @@ init_field(struct dialog_data *dlg_data, struct widget_data *widget_data) struct input_history_entry *new_entry; /* One byte is reserved in struct input_history_entry. */ - new_entry = mem_alloc(sizeof(*new_entry) + datalen); + new_entry = (struct input_history_entry *)mem_alloc(sizeof(*new_entry) + datalen); if (!new_entry) continue; memcpy(new_entry->data, entry->data, datalen + 1); diff --git a/src/bfu/inphist.c b/src/bfu/inphist.c index 66c4ba9a..36bce468 100644 --- a/src/bfu/inphist.c +++ b/src/bfu/inphist.c @@ -260,7 +260,7 @@ add_to_input_history(struct input_history *history, char *data, /* Copy it all etc. */ /* One byte is already reserved for url in struct input_history_item. */ - entry = mem_alloc(sizeof(*entry) + length); + entry = (struct input_history_entry *)mem_alloc(sizeof(*entry) + length); if (!entry) return; memcpy(entry->data, data, length + 1); diff --git a/src/bfu/msgbox.c b/src/bfu/msgbox.c index 8ab60c5e..c5ecbc4f 100644 --- a/src/bfu/msgbox.c +++ b/src/bfu/msgbox.c @@ -103,7 +103,7 @@ msg_text_do(char *format, va_list ap) va_copy(ap2, ap); infolen = vsnprintf(NULL, 0, format, ap2); - info = mem_alloc(infolen + 1); + info = (char *)mem_alloc(infolen + 1); if (!info) return NULL; len = vsnprintf((char *) info, infolen + 1, format, ap); diff --git a/src/bookmarks/backend/xbel.c b/src/bookmarks/backend/xbel.c index aa954981..84208c05 100644 --- a/src/bookmarks/backend/xbel.c +++ b/src/bookmarks/backend/xbel.c @@ -308,7 +308,7 @@ delete_whites(const char *s) int last_was_space = 0, c = 0, i; int len = strlen(s); - r = mem_alloc(len + 1); + r = (char *)mem_alloc(len + 1); if (!r) return NULL; for (i = 0; i < len; i++) { @@ -350,7 +350,7 @@ on_text(void *data, const XML_Char *text, int len) if (len) { len2 = current_node->text ? strlen(current_node->text) : 0; - tmp = mem_realloc(current_node->text, (size_t) (len + 1 + len2)); + tmp = (char *)mem_realloc(current_node->text, (size_t) (len + 1 + len2)); /* Out of memory */ if (!tmp) return; diff --git a/src/config/dialogs.c b/src/config/dialogs.c index 6db511e0..a3736e7e 100644 --- a/src/config/dialogs.c +++ b/src/config/dialogs.c @@ -469,7 +469,7 @@ invalid_option: goto invalid_option; } - ctx = mem_alloc(sizeof(*ctx)); + ctx = (struct add_option_to_tree_ctx *)mem_alloc(sizeof(*ctx)); if (!ctx) return EVENT_PROCESSED; ctx->option = option; ctx->widget_data = dlg_data->widgets_data; @@ -759,7 +759,7 @@ struct kbdbind_add_hop { static struct kbdbind_add_hop * new_hop_from(struct kbdbind_add_hop *hop) { - struct kbdbind_add_hop *new_hop = mem_alloc(sizeof(*new_hop)); + struct kbdbind_add_hop *new_hop = (struct kbdbind_add_hop *)mem_alloc(sizeof(*new_hop)); if (new_hop) copy_struct(new_hop, hop); diff --git a/src/config/domain.c b/src/config/domain.c index 62a942bc..a78d9ccd 100644 --- a/src/config/domain.c +++ b/src/config/domain.c @@ -80,7 +80,7 @@ get_domain_tree(char *domain_name) domain_len = strlen(domain_name); /* One byte is reserved for domain in struct domain_tree. */ - domain = mem_alloc(sizeof(*domain) + domain_len); + domain = (struct domain_tree *)mem_alloc(sizeof(*domain) + domain_len); if (!domain) return NULL; domain->tree = copy_option(config_options, CO_SHALLOW diff --git a/src/config/options.c b/src/config/options.c index 32ccbeab..233bcb4b 100644 --- a/src/config/options.c +++ b/src/config/options.c @@ -759,7 +759,7 @@ get_option_shadow(struct option *option, struct option *tree, LIST_OF(struct option) * init_options_tree(void) { - LIST_OF(struct option) *ptr = mem_alloc(sizeof(*ptr)); + LIST_OF(struct option) *ptr = (LIST_OF(struct option) *)mem_alloc(sizeof(*ptr)); if (ptr) init_list(*ptr); return ptr; @@ -1341,7 +1341,7 @@ register_options(union option_info info[], struct option *tree) } break; case OPT_STRING: - string = mem_alloc(MAX_STR_LEN); + string = (char *)mem_alloc(MAX_STR_LEN); if (!string) { delete_option(option); continue; diff --git a/src/config/options.h b/src/config/options.h index 64afa964..aeb66c67 100644 --- a/src/config/options.h +++ b/src/config/options.h @@ -370,7 +370,7 @@ extern struct option *add_opt(struct option *, char *, char *, /*! @relates option */ #define add_opt_str_tree(tree, path, capt, name, flags, def, desc) \ do { \ - char *ptr = mem_alloc(MAX_STR_LEN); \ + char *ptr = (char *)mem_alloc(MAX_STR_LEN); \ safe_strncpy(ptr, def, MAX_STR_LEN); \ add_opt(tree, path, capt, name, flags, OPT_STRING, 0, MAX_STR_LEN, (longptr_T) ptr, DESC(desc)); \ } while (0) diff --git a/src/config/opttypes.c b/src/config/opttypes.c index c4144113..108d994f 100644 --- a/src/config/opttypes.c +++ b/src/config/opttypes.c @@ -202,7 +202,7 @@ static char * num_rd(struct option *opt, char **file, int *line) { char *end = *file; - long *value = mem_alloc(sizeof(*value)); + long *value = (long *)mem_alloc(sizeof(*value)); if (!value) return NULL; @@ -347,7 +347,7 @@ str_wr(struct option *o, struct string *s) static void str_dup(struct option *opt, struct option *template_, int flags) { - char *new_ = mem_alloc(MAX_STR_LEN); + char *new_ = (char *)mem_alloc(MAX_STR_LEN); if (new_) safe_strncpy(new_, template_->value.string, MAX_STR_LEN); opt->value.string = new_; diff --git a/src/cookies/cookies.c b/src/cookies/cookies.c index 56823659..a6c52740 100644 --- a/src/cookies/cookies.c +++ b/src/cookies/cookies.c @@ -519,7 +519,7 @@ accept_cookie(struct cookie *cookie) domain_len = strlen(cookie->domain); /* One byte is reserved for domain in struct c_domain. */ - cd = mem_alloc(sizeof(*cd) + domain_len); + cd = (struct c_domain *)mem_alloc(sizeof(*cd) + domain_len); if (!cd) return; memcpy(cd->domain, cookie->domain, domain_len + 1); diff --git a/src/dialogs/document.c b/src/dialogs/document.c index 5fde0998..e5d2b853 100644 --- a/src/dialogs/document.c +++ b/src/dialogs/document.c @@ -286,7 +286,7 @@ cached_header_dialog(struct session *ses, struct cache_entry *cached) title = N_("Internal header info"); #endif - headers = mem_alloc(strlen(cached->head) + 1); + headers = (char *)mem_alloc(strlen(cached->head) + 1); if (!headers) return; /* Sanitize headers string. */ diff --git a/src/dialogs/menu.c b/src/dialogs/menu.c index 90937d2b..8e820e90 100644 --- a/src/dialogs/menu.c +++ b/src/dialogs/menu.c @@ -352,7 +352,7 @@ do_file_menu(struct terminal *term, void *xxx, void *ses_) int anonymous = get_cmd_opt_bool("anonymous"); int x, o; - file_menu = mem_alloc(sizeof(file_menu11) + sizeof(file_menu21) + file_menu = (struct menu_item *)mem_alloc(sizeof(file_menu11) + sizeof(file_menu21) + sizeof(file_menu22) + sizeof(file_menu3) + 3 * sizeof(struct menu_item)); if (!file_menu) return; diff --git a/src/document/css/stylesheet.c b/src/document/css/stylesheet.c index 42bb3e00..79a77ab6 100644 --- a/src/document/css/stylesheet.c +++ b/src/document/css/stylesheet.c @@ -129,7 +129,7 @@ copy_css_selector(struct css_stylesheet *css, struct css_selector *orig) static void add_selector_property(struct css_selector *selector, struct css_property *prop) { - struct css_property *newprop = mem_alloc(sizeof(*newprop)); + struct css_property *newprop = (struct css_property *)mem_alloc(sizeof(*newprop)); if (newprop) { copy_struct(newprop, prop); diff --git a/src/document/dom/util.c b/src/document/dom/util.c index 59a2b8c8..9df52f2e 100644 --- a/src/document/dom/util.c +++ b/src/document/dom/util.c @@ -100,7 +100,7 @@ realloc_line(struct document *document, int x, int y) static struct node * add_search_node(struct dom_renderer *renderer, int width) { - struct node *node = mem_alloc(sizeof(*node)); + struct node *node = (struct node *)mem_alloc(sizeof(*node)); if (node) { set_box(&node->box, renderer->canvas_x, renderer->canvas_y, diff --git a/src/document/html/frames.c b/src/document/html/frames.c index 5306ae69..22443aba 100644 --- a/src/document/html/frames.c +++ b/src/document/html/frames.c @@ -350,7 +350,7 @@ distribute_rows_or_cols_that_left(int *val_, int max_value, int *values, int val int divisor = 0; int tmp_val; - tmp_values = fmem_alloc(values_count * sizeof(*tmp_values)); + tmp_values = (int *)fmem_alloc(values_count * sizeof(*tmp_values)); if (!tmp_values) return 0; memcpy(tmp_values, values, values_count * sizeof(*tmp_values)); diff --git a/src/document/html/parser.c b/src/document/html/parser.c index 5da530f4..4dab7373 100644 --- a/src/document/html/parser.c +++ b/src/document/html/parser.c @@ -572,7 +572,7 @@ look_for_link(char **pos, char *eof, struct menu_item **menu, return 1; } - ld = mem_alloc(sizeof(*ld)); + ld = (struct link_def *)mem_alloc(sizeof(*ld)); if (!ld) { mem_free_if(label); mem_free(target); diff --git a/src/document/html/parser/link.c b/src/document/html/parser/link.c index 3138864e..bd18affe 100644 --- a/src/document/html/parser/link.c +++ b/src/document/html/parser/link.c @@ -125,7 +125,7 @@ truncate_label(char *label, int max_len) if (left_part_len + right_part_len + 1 > max_len) right_part_len--; - new_label = mem_alloc(max_len + 1); + new_label = (char *)mem_alloc(max_len + 1); if (!new_label) return NULL; if (left_part_len) diff --git a/src/document/html/parser/parse.c b/src/document/html/parser/parse.c index b7e8ba73..1281f200 100644 --- a/src/document/html/parser/parse.c +++ b/src/document/html/parser/parse.c @@ -779,7 +779,7 @@ next_break: dotcounter++; base_pos = ++html; if (*html >= ' ' || isspace(*html) || html >= eof) { - char *dots = fmem_alloc(dotcounter); + char *dots = (char *)fmem_alloc(dotcounter); if (dots) { memset(dots, '.', dotcounter); diff --git a/src/document/html/parser/stack.c b/src/document/html/parser/stack.c index 5e60e57c..3003ab67 100644 --- a/src/document/html/parser/stack.c +++ b/src/document/html/parser/stack.c @@ -154,7 +154,7 @@ html_stack_dup(struct html_context *html_context, enum html_element_mortality_ty assertm(ep && (void *) ep != &html_context->stack, "html stack empty"); if_assert_failed return; - e = mem_alloc(sizeof(*e)); + e = (struct html_element *)mem_alloc(sizeof(*e)); if (!e) return; copy_struct(e, ep); diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index e7a87763..3599b4a1 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -981,7 +981,7 @@ shift_chars(struct html_context *html_context, int y, int shift) len = LEN(y); - a = fmem_alloc(len * sizeof(*a)); + a = (struct screen_char *)fmem_alloc(len * sizeof(*a)); if (!a) return; copy_screen_chars(a, &POS(0, y), len); @@ -1240,13 +1240,13 @@ justify_line(struct html_context *html_context, int y) assert(len > 0); if_assert_failed return; - line = fmem_alloc(len * sizeof(*line)); + line = (struct screen_char *)fmem_alloc(len * sizeof(*line)); if (!line) return; /* It may sometimes happen that the line is only one char long and that * char is space - then we're going to write to both [0] and [1], but * we allocated only one field. Thus, we've to do (len + 1). --pasky */ - space_list = fmem_alloc((len + 1) * sizeof(*space_list)); + space_list = (int *)fmem_alloc((len + 1) * sizeof(*space_list)); if (!space_list) { fmem_free(line); return; @@ -1537,7 +1537,7 @@ html_special_tag(struct document *document, char *t, int x, int y) tag_len = strlen(t); /* One byte is reserved for name in struct tag. */ - tag = mem_alloc(sizeof(*tag) + tag_len); + tag = (struct tag *)mem_alloc(sizeof(*tag) + tag_len); if (!tag) return; tag->x = x; @@ -2431,7 +2431,7 @@ format_html_part(struct html_context *html_context, (char *) &key, sizeof(key)); if (item) { /* We found it in cache, so just copy and return. */ - part = mem_alloc(sizeof(*part)); + part = (struct part *)mem_alloc(sizeof(*part)); if (part) { copy_struct(part, &((struct table_cache_entry *) item->value)->part); @@ -2444,7 +2444,7 @@ format_html_part(struct html_context *html_context, if_assert_failed return NULL; if (document) { - struct node *node = mem_alloc(sizeof(*node)); + struct node *node = (struct node *)mem_alloc(sizeof(*node)); if (node) { int node_width = !html_context->table_level ? INT_MAX : width; diff --git a/src/document/html/tables.c b/src/document/html/tables.c index daa66632..c79e59e2 100644 --- a/src/document/html/tables.c +++ b/src/document/html/tables.c @@ -499,10 +499,10 @@ distribute_widths(struct table *table, int width) memcpy(table->cols_widths, table->min_cols_widths, cols_array_size); table->real_width = width; - widths = fmem_alloc(cols_array_size); + widths = (int *)fmem_alloc(cols_array_size); if (!widths) return; - max_widths = fmem_alloc(cols_array_size); + max_widths = (int *)fmem_alloc(cols_array_size); if (!max_widths) goto free_widths; while (spare_width) { @@ -1134,7 +1134,7 @@ draw_table_frames(struct table *table, int indent, int y, int fh_size = (table->cols + 2) * (table->rows + 1); int fv_size = (table->cols + 1) * (table->rows + 2); - frame[0] = fmem_alloc(fh_size + fv_size); + frame[0] = (signed char *)fmem_alloc(fh_size + fv_size); if (!frame[0]) return; memset(frame[0], -1, fh_size + fv_size); @@ -1345,7 +1345,7 @@ format_table(char *attr, char *html, char *eof, part->cy += table->real_height; part->cx = -1; - new_node = mem_alloc(sizeof(*new_node)); + new_node = (struct node *)mem_alloc(sizeof(*new_node)); if (new_node) { set_box(&new_node->box, node->box.x, part->box.y + part->cy, node->box.width, 0); diff --git a/src/document/plain/renderer.c b/src/document/plain/renderer.c index 493dbbc5..ad7f2c86 100644 --- a/src/document/plain/renderer.c +++ b/src/document/plain/renderer.c @@ -717,7 +717,7 @@ init_template(struct screen_char *template_, struct document_options *options) static struct node * add_node(struct plain_renderer *renderer, int x, int width, int height) { - struct node *node = mem_alloc(sizeof(*node)); + struct node *node = (struct node *)mem_alloc(sizeof(*node)); if (node) { struct document *document = renderer->document; diff --git a/src/document/refresh.c b/src/document/refresh.c index d5eaff8f..a323121e 100644 --- a/src/document/refresh.c +++ b/src/document/refresh.c @@ -31,7 +31,7 @@ init_document_refresh(char *url, unsigned long seconds) { struct document_refresh *refresh; - refresh = mem_alloc(sizeof(*refresh)); + refresh = (struct document_refresh *)mem_alloc(sizeof(*refresh)); if (!refresh) return NULL; refresh->uri = get_uri(url, URI_NONE); diff --git a/src/document/xml/renderer2.c b/src/document/xml/renderer2.c index 02b09c3a..a0c58c9a 100644 --- a/src/document/xml/renderer2.c +++ b/src/document/xml/renderer2.c @@ -164,7 +164,7 @@ next_break: dotcounter++; base_pos = ++html; if (*html >= ' ' || isspace(*html) || html >= eof) { - char *dots = fmem_alloc(dotcounter); + char *dots = (char *)fmem_alloc(dotcounter); if (dots) { memset(dots, '.', dotcounter); diff --git a/src/document/xml/tables.c b/src/document/xml/tables.c index dfca7f44..d41d35a4 100644 --- a/src/document/xml/tables.c +++ b/src/document/xml/tables.c @@ -919,7 +919,7 @@ tags_format_table(struct source_renderer *renderer, void *no) part->cy += table->real_height; part->cx = -1; - new_node = mem_alloc(sizeof(*new_node)); + new_node = (struct node *)mem_alloc(sizeof(*new_node)); if (new_node) { set_box(&new_node->box, node->box.x, part->box.y + part->cy, node->box.width, 0); diff --git a/src/document/xml/tags.c b/src/document/xml/tags.c index 0e6b9c49..a9c3c2ec 100644 --- a/src/document/xml/tags.c +++ b/src/document/xml/tags.c @@ -1699,7 +1699,7 @@ truncate_label(unsigned char *label, int max_len) if (left_part_len + right_part_len + 1 > max_len) right_part_len--; - new_label = mem_alloc(max_len + 1); + new_label = (unsigned char *)mem_alloc(max_len + 1); if (!new_label) return NULL; if (left_part_len) diff --git a/src/dom/test/sgml-parser.c b/src/dom/test/sgml-parser.c index ac14fc8f..62a5c2a3 100644 --- a/src/dom/test/sgml-parser.c +++ b/src/dom/test/sgml-parser.c @@ -318,7 +318,7 @@ main(int argc, char *argv[]) if (read_stdin > 0) { char *buffer; - buffer = mem_alloc(read_stdin); + buffer = (char *)mem_alloc(read_stdin); if (!buffer) die("Cannot allocate buffer"); diff --git a/src/ecmascript/quickjs/heartbeat.c b/src/ecmascript/quickjs/heartbeat.c index b57d81c2..fa54d370 100644 --- a/src/ecmascript/quickjs/heartbeat.c +++ b/src/ecmascript/quickjs/heartbeat.c @@ -83,7 +83,7 @@ add_heartbeat(struct ecmascript_interpreter *interpreter) ses = NULL; else ses = interpreter->vs->doc_view->session; - hb = mem_alloc(sizeof(struct heartbeat)); + hb = (struct heartbeat *)mem_alloc(sizeof(struct heartbeat)); if (!hb) return NULL; diff --git a/src/ecmascript/spidermonkey/heartbeat.c b/src/ecmascript/spidermonkey/heartbeat.c index b40b4052..5a9dc01d 100644 --- a/src/ecmascript/spidermonkey/heartbeat.c +++ b/src/ecmascript/spidermonkey/heartbeat.c @@ -93,7 +93,7 @@ add_heartbeat(struct ecmascript_interpreter *interpreter) ses = NULL; else ses = interpreter->vs->doc_view->session; - hb = mem_alloc(sizeof(struct heartbeat)); + hb = (struct heartbeat *)mem_alloc(sizeof(struct heartbeat)); if (!hb) return NULL; diff --git a/src/encoding/bzip2.c b/src/encoding/bzip2.c index 99636767..69df7a42 100644 --- a/src/encoding/bzip2.c +++ b/src/encoding/bzip2.c @@ -54,7 +54,7 @@ bzip2_open(struct stream_encoded *stream, int fd) * pointer.) */ static const bz_stream null_bz_stream = {0}; - struct bz2_enc_data *data = mem_alloc(sizeof(*data)); + struct bz2_enc_data *data = (struct bz2_enc_data *)mem_alloc(sizeof(*data)); int err; stream->data = NULL; diff --git a/src/encoding/encoding.c b/src/encoding/encoding.c index dfc22ef1..43cebd5a 100644 --- a/src/encoding/encoding.c +++ b/src/encoding/encoding.c @@ -110,7 +110,7 @@ open_encoded(int fd, enum stream_encoding encoding) { struct stream_encoded *stream; - stream = mem_alloc(sizeof(*stream)); + stream = (struct stream_encoded *)mem_alloc(sizeof(*stream)); if (!stream) return NULL; stream->encoding = encoding; diff --git a/src/encoding/gzip.c b/src/encoding/gzip.c index e5ee99b4..dfb64f5c 100644 --- a/src/encoding/gzip.c +++ b/src/encoding/gzip.c @@ -47,7 +47,7 @@ deflate_open(int window_size, struct stream_encoded *stream, int fd) static const z_stream null_z_stream = {0}; int err; - struct deflate_enc_data *data = mem_alloc(sizeof(*data)); + struct deflate_enc_data *data = (struct deflate_enc_data *)mem_alloc(sizeof(*data)); stream->data = NULL; if (!data) { diff --git a/src/encoding/lzma.c b/src/encoding/lzma.c index b079881a..b870e6cb 100644 --- a/src/encoding/lzma.c +++ b/src/encoding/lzma.c @@ -35,7 +35,7 @@ struct lzma_enc_data { static int lzma_open(struct stream_encoded *stream, int fd) { - struct lzma_enc_data *data = mem_alloc(sizeof(*data)); + struct lzma_enc_data *data = (struct lzma_enc_data *)mem_alloc(sizeof(*data)); int err; stream->data = NULL; diff --git a/src/formhist/formhist.c b/src/formhist/formhist.c index e61b3fb3..4a5f8d7f 100644 --- a/src/formhist/formhist.c +++ b/src/formhist/formhist.c @@ -54,7 +54,7 @@ new_formhist_item(char *url) if (!form) return NULL; memcpy(form->url, url, url_len); - form->submit = mem_alloc(sizeof(*form->submit)); + form->submit = (LIST_OF(struct submitted_value) *)mem_alloc(sizeof(*form->submit)); if (!form->submit) { mem_free(form); return NULL; } object_nolock(form, "formhist"); diff --git a/src/intl/charsets.c b/src/intl/charsets.c index 8cb2eb8a..be1e9905 100644 --- a/src/intl/charsets.c +++ b/src/intl/charsets.c @@ -814,7 +814,7 @@ get_combined(unicode_val_T *data, int length) if (item) return (unicode_val_T)(long)item->value; if (last_combined >= UCS_END_COMBINED) return UCS_NO_CHAR; - key = mem_alloc((length + 1) * sizeof(*key)); + key = (unicode_val_T *)mem_alloc((length + 1) * sizeof(*key)); if (!key) return UCS_NO_CHAR; for (i = 0; i < length; i++) key[i] = data[i]; @@ -1314,7 +1314,7 @@ convert_string(struct conv_table *convert_table, /* Buffer allocation */ - buffer = mem_alloc(ALLOC_GR + 1 /* trailing \0 */); + buffer = (char *)mem_alloc(ALLOC_GR + 1 /* trailing \0 */); if (!buffer) return NULL; #ifdef HAVE_ICONV diff --git a/src/intl/gettext/loadmsgcat.c b/src/intl/gettext/loadmsgcat.c index c2863189..101362e4 100644 --- a/src/intl/gettext/loadmsgcat.c +++ b/src/intl/gettext/loadmsgcat.c @@ -152,7 +152,7 @@ _nl_init_domain_conv(struct loaded_l10nfile *domain_file, charsetstr += strlen("charset="); len = strcspn(charsetstr, " \t\n"); - charset = (char *) fmem_alloc(len + 1); + charset = (char *)fmem_alloc(len + 1); *((char *) mempcpy(charset, charsetstr, len)) = '\0'; /* The output charset should normally be determined by the @@ -176,7 +176,7 @@ _nl_init_domain_conv(struct loaded_l10nfile *domain_file, #if _LIBICONV_VERSION >= 0x0105 len = strlen(outcharset); { - char *tmp = (char *) fmem_alloc(len + 10 + 1); + char *tmp = (char *)fmem_alloc(len + 10 + 1); memcpy(tmp, outcharset, len); memcpy(tmp + len, "//TRANSLIT", 10 + 1); diff --git a/src/intl/gettext/localealias.c b/src/intl/gettext/localealias.c index 141130aa..70f05649 100644 --- a/src/intl/gettext/localealias.c +++ b/src/intl/gettext/localealias.c @@ -127,7 +127,7 @@ read_alias_file(const char *fname, int fname_len) size_t added; static const char aliasfile[] = "/locale.alias"; - full_fname = (char *) fmem_alloc(fname_len + sizeof(aliasfile)); + full_fname = (char *)fmem_alloc(fname_len + sizeof(aliasfile)); mempcpy(mempcpy(full_fname, fname, fname_len), aliasfile, sizeof(aliasfile)); diff --git a/src/main/select.c b/src/main/select.c index 61749d10..792b2607 100644 --- a/src/main/select.c +++ b/src/main/select.c @@ -154,7 +154,7 @@ register_bottom_half_do(select_handler_T fn, void *data) if (bh->fn == fn && bh->data == data) return 0; - bh = mem_alloc(sizeof(*bh)); + bh = (struct bottom_half *)mem_alloc(sizeof(*bh)); if (!bh) return -1; bh->fn = fn; bh->data = data; @@ -255,7 +255,7 @@ set_event_for_action(int h, void (*func)(void *), struct event **evptr, short ev #ifdef EV_PERSIST evtype |= EV_PERSIST; #endif - *evptr = mem_alloc(sizeof_struct_event); + *evptr = (struct event *)mem_alloc(sizeof_struct_event); event_set(*evptr, h, evtype, event_callback, *evptr); #ifdef HAVE_EVENT_BASE_SET if (event_base_set(event_base, *evptr) == -1) diff --git a/src/main/timer.c b/src/main/timer.c index a4907c8b..163df5ba 100644 --- a/src/main/timer.c +++ b/src/main/timer.c @@ -167,10 +167,10 @@ install_timer(timer_id_T *id, milliseconds_T delay, void (*func)(void *), void * assert(id && delay > 0); #ifdef USE_LIBEVENT - char *q = mem_alloc(sizeof_struct_event + sizeof(struct timer)); + char *q = (char *)mem_alloc(sizeof_struct_event + sizeof(struct timer)); new_timer = (struct timer *)(q + sizeof_struct_event); #else - new_timer = mem_alloc(sizeof(*new_timer)); + new_timer = (struct timer *)mem_alloc(sizeof(*new_timer)); #endif *id = (timer_id_T) new_timer; /* TIMER_ID_UNDEF is NULL */ if (!new_timer) return; diff --git a/src/mime/backend/mailcap.c b/src/mime/backend/mailcap.c index 373b6ff8..5ac1f12f 100644 --- a/src/mime/backend/mailcap.c +++ b/src/mime/backend/mailcap.c @@ -172,7 +172,7 @@ add_mailcap_entry(struct mailcap_entry *entry, char *type, int typelen) /* First check if the type is already checked in */ item = get_hash_item(mailcap_map, type, typelen); if (!item) { - mitem = mem_alloc(sizeof(*mitem) + typelen); + mitem = (struct mailcap_hash_item *)mem_alloc(sizeof(*mitem) + typelen); if (!mitem) { done_mailcap_entry(entry); return; diff --git a/src/network/dns.c b/src/network/dns.c index bf95960d..19960b56 100644 --- a/src/network/dns.c +++ b/src/network/dns.c @@ -110,7 +110,7 @@ add_to_dns_cache(char *name, struct sockaddr_storage *addr, int addrno) if (!dnsentry) return; size = addrno * sizeof(*dnsentry->addr); - dnsentry->addr = mem_alloc(size); + dnsentry->addr = (struct sockaddr_storage *)mem_alloc(size); if (!dnsentry->addr) { mem_free(dnsentry); return; diff --git a/src/network/socket.c b/src/network/socket.c index 27388476..f053f843 100644 --- a/src/network/socket.c +++ b/src/network/socket.c @@ -234,7 +234,7 @@ dns_found(struct socket *socket, struct sockaddr_storage *addr, int addrlen) size = sizeof(*addr) * addrlen; - connect_info->addr = mem_alloc(size); + connect_info->addr = (struct sockaddr_storage *)mem_alloc(size); if (!connect_info->addr) { socket->ops->done(socket, connection_state(S_OUT_OF_MEM)); return; @@ -894,7 +894,7 @@ write_to_socket(struct socket *socket, char *data, int len, socket->ops->set_timeout(socket, connection_state(0)); - wb = mem_alloc(sizeof(*wb) + len); + wb = (struct write_buffer *)mem_alloc(sizeof(*wb) + len); if (!wb) { socket->ops->done(socket, connection_state(S_OUT_OF_MEM)); return; diff --git a/src/network/ssl/ssl.c b/src/network/ssl/ssl.c index d582b6d7..edc060cf 100644 --- a/src/network/ssl/ssl.c +++ b/src/network/ssl/ssl.c @@ -377,7 +377,7 @@ init_ssl_connection(struct socket *socket, } #elif defined(CONFIG_GNUTLS) - ssl_t *state = mem_alloc(sizeof(ssl_t)); + ssl_t *state = (ssl_t *)mem_alloc(sizeof(ssl_t)); if (!state) return S_SSL_ERROR; diff --git a/src/osdep/os2/os2.c b/src/osdep/os2/os2.c index e0797188..7e1c6394 100644 --- a/src/osdep/os2/os2.c +++ b/src/osdep/os2/os2.c @@ -283,7 +283,7 @@ get_window_title(int codepage) if (hab != NULLHANDLE) { hmq = WinCreateMsgQueue(hab, 0); if (hmq != NULLHANDLE) { - org_win_title = mem_alloc(MAXNAMEL + 1); + org_win_title = (char *)mem_alloc(MAXNAMEL + 1); if (org_win_title) WinQueryWindowText(swData.hwnd, MAXNAMEL + 1, @@ -367,13 +367,13 @@ set_window_title(int init, const char *url) memset(&swData, 0, sizeof(swData)); hSw = WinQuerySwitchHandle(0, pib->pib_ulpid); if (hSw != NULLHANDLE && !WinQuerySwitchEntry(hSw, &swData)) { - org_switch_title = mem_alloc(strlen(swData.szSwtitle) + 1); + org_switch_title = (char *)mem_alloc(strlen(swData.szSwtitle) + 1); strcpy(org_switch_title, swData.szSwtitle); pib->pib_ultype = 3; hab = WinInitialize(0); hmq = WinCreateMsgQueue(hab, 0); if (hab != NULLHANDLE && hmq != NULLHANDLE) { - org_win_title = mem_alloc(MAXNAMEL + 1); + org_win_title = (char *)mem_alloc(MAXNAMEL + 1); WinQueryWindowText(swData.hwnd, MAXNAMEL + 1, org_win_title); WinDestroyMsgQueue(hmq); WinTerminate(hab); diff --git a/src/osdep/osdep.c b/src/osdep/osdep.c index 03ab40a8..8a80f8d8 100644 --- a/src/osdep/osdep.c +++ b/src/osdep/osdep.c @@ -145,7 +145,7 @@ get_cwd(void) char *buf; while (1) { - buf = mem_alloc(bufsize); + buf = (char *)mem_alloc(bufsize); if (!buf) return NULL; if (getcwd(buf, bufsize)) return buf; mem_free(buf); diff --git a/src/osdep/unix/unix.c b/src/osdep/unix/unix.c index 29847e0f..45773244 100644 --- a/src/osdep/unix/unix.c +++ b/src/osdep/unix/unix.c @@ -107,7 +107,7 @@ handle_mouse(int cons, void (*fn)(void *, char *, int), h = init_mouse(cons, 0); if (h < 0) return NULL; - gms = mem_alloc(sizeof(*gms)); + gms = (struct gpm_mouse_spec *)mem_alloc(sizeof(*gms)); if (!gms) return NULL; gms->h = h; gms->cons = cons; diff --git a/src/protocol/bittorrent/common.c b/src/protocol/bittorrent/common.c index 394062bf..079fd965 100644 --- a/src/protocol/bittorrent/common.c +++ b/src/protocol/bittorrent/common.c @@ -285,7 +285,7 @@ add_bittorrent_peer_request(struct bittorrent_peer_status *status, request = get_bittorrent_peer_request(status, piece, offset, length); if (request) return; - request = mem_alloc(sizeof(*request)); + request = (struct bittorrent_peer_request *)mem_alloc(sizeof(*request)); if (!request) return; request->piece = piece; diff --git a/src/protocol/bittorrent/peerwire.c b/src/protocol/bittorrent/peerwire.c index 7cc2fa5f..40c5c661 100644 --- a/src/protocol/bittorrent/peerwire.c +++ b/src/protocol/bittorrent/peerwire.c @@ -402,7 +402,7 @@ send_bittorrent_peer_message(struct bittorrent_peer_connection *peer, va_end(args); - message = mem_alloc(sizeof(*message)); + message = (struct bittorrent_peer_request *)mem_alloc(sizeof(*message)); if (!message) return; memcpy(message, &message_store, sizeof(*message)); diff --git a/src/protocol/bittorrent/piececache.c b/src/protocol/bittorrent/piececache.c index 94b9256f..589fdcbf 100644 --- a/src/protocol/bittorrent/piececache.c +++ b/src/protocol/bittorrent/piececache.c @@ -324,7 +324,7 @@ clone_bittorrent_peer_request(struct bittorrent_peer_request *request) { struct bittorrent_peer_request *clone; - clone = mem_alloc(sizeof(*clone)); + clone = (struct bittorrent_peer_request *)mem_alloc(sizeof(*clone)); if (!clone) return NULL; /* Both are now clones ... */ diff --git a/src/protocol/header.c b/src/protocol/header.c index da75876b..bd283679 100644 --- a/src/protocol/header.c +++ b/src/protocol/header.c @@ -333,7 +333,7 @@ again: while (start < e && *(e - 1) == ' ') e--; if (start == e) return NULL; - n = mem_alloc(e - start + 1); + n = (char *)mem_alloc(e - start + 1); if (n) { int i = 0; diff --git a/src/protocol/http/blacklist.c b/src/protocol/http/blacklist.c index 7e565bc9..1a708d1b 100644 --- a/src/protocol/http/blacklist.c +++ b/src/protocol/http/blacklist.c @@ -53,7 +53,7 @@ add_blacklist_entry(struct uri *uri, enum blacklist_flags flags) return; } - entry = mem_alloc(sizeof(*entry) + uri->hostlen); + entry = (struct blacklist_entry *)mem_alloc(sizeof(*entry) + uri->hostlen); if (!entry) return; entry->flags = flags; diff --git a/src/protocol/uri.c b/src/protocol/uri.c index 2099a96d..f155c5b2 100644 --- a/src/protocol/uri.c +++ b/src/protocol/uri.c @@ -1000,7 +1000,7 @@ join_urls(struct uri *base, char *rel) } length = path - struri(base); - uristring = mem_alloc(length + strlen(rel) + add_slash + 1); + uristring = (char *)mem_alloc(length + strlen(rel) + add_slash + 1); if (!uristring) return NULL; memcpy(uristring, struri(base), length); diff --git a/src/scripting/python/dialogs.c b/src/scripting/python/dialogs.c index 94f9d63a..02c1cd73 100644 --- a/src/scripting/python/dialogs.c +++ b/src/scripting/python/dialogs.c @@ -202,7 +202,7 @@ python_input_box(PyObject *self, PyObject *args, PyObject *kwargs) if (!initial) goto free_title; } - hop = mem_alloc(sizeof(*hop)); + hop = (struct python_input_callback_hop *)mem_alloc(sizeof(*hop)); if (!hop) goto free_initial; hop->ses = python_ses; hop->callback = callback; diff --git a/src/scripting/python/load.c b/src/scripting/python/load.c index 74a47934..c7887780 100644 --- a/src/scripting/python/load.c +++ b/src/scripting/python/load.c @@ -122,10 +122,10 @@ python_load(PyObject *self, PyObject *args) return NULL; } - download = mem_alloc(sizeof(*download)); + download = (struct download *)mem_alloc(sizeof(*download)); if (!download) goto mem_error; - hop = mem_alloc(sizeof(*hop)); + hop = (struct python_load_uri_callback_hop *)mem_alloc(sizeof(*hop)); if (!hop) goto free_download; hop->ses = python_ses; hop->callback = callback; diff --git a/src/scripting/smjs/action_object.c b/src/scripting/smjs/action_object.c index 3032902f..26424ed1 100644 --- a/src/scripting/smjs/action_object.c +++ b/src/scripting/smjs/action_object.c @@ -138,7 +138,7 @@ smjs_get_action_fn_object(char *action_str) obj = JS_NewObject(smjs_ctx, (JSClass *) &action_fn_class); if (!obj) return NULL; - hop = mem_alloc(sizeof(*hop)); + hop = (struct smjs_action_fn_callback_hop *)mem_alloc(sizeof(*hop)); if (!hop) return NULL; hop->ses = smjs_ses; diff --git a/src/scripting/smjs/load_uri.c b/src/scripting/smjs/load_uri.c index 99df1da1..9c6f4395 100644 --- a/src/scripting/smjs/load_uri.c +++ b/src/scripting/smjs/load_uri.c @@ -96,13 +96,13 @@ smjs_load_uri(JSContext *ctx, unsigned int argc, JS::Value *rval) return false; } - download = mem_alloc(sizeof(*download)); + download = (struct download *)mem_alloc(sizeof(*download)); if (!download) { done_uri(uri); return false; } - hop = mem_alloc(sizeof(*hop)); + hop = (struct smjs_load_uri_hop *)mem_alloc(sizeof(*hop)); if (!hop) { mem_free(download); done_uri(uri); diff --git a/src/session/session.c b/src/session/session.c index 2f6730e1..7c72d64d 100644 --- a/src/session/session.c +++ b/src/session/session.c @@ -609,7 +609,7 @@ check_questions_queue(struct session *ses) void add_questions_entry(void (*callback)(struct session *, void *), void *data) { - struct questions_entry *q = mem_alloc(sizeof(*q)); + struct questions_entry *q = (struct questions_entry *)mem_alloc(sizeof(*q)); if (!q) return; diff --git a/src/session/task.c b/src/session/task.c index 6ff9d569..ae8de23b 100644 --- a/src/session/task.c +++ b/src/session/task.c @@ -238,7 +238,7 @@ ses_goto(struct session *ses, struct uri *uri, char *target_frame, return; } - task = mem_alloc(sizeof(*task)); + task = (struct task *)mem_alloc(sizeof(*task)); if (!task) return; task->ses = ses; diff --git a/src/terminal/kbd.c b/src/terminal/kbd.c index b762d02d..55333dc7 100644 --- a/src/terminal/kbd.c +++ b/src/terminal/kbd.c @@ -653,7 +653,7 @@ has_nul_byte: del_len = delete_.length; param_len = path_len + del_len + 3; - param = mem_alloc(param_len); + param = (char *)mem_alloc(param_len); if (!param) goto nasty_thing; param[0] = fg; diff --git a/src/terminal/screen.c b/src/terminal/screen.c index b3889a38..c9837ef8 100644 --- a/src/terminal/screen.c +++ b/src/terminal/screen.c @@ -595,7 +595,7 @@ add_screen_driver(enum term_mode_type type, struct terminal *term, int env_len) struct screen_driver *driver; /* One byte is reserved for name in struct screen_driver. */ - driver = mem_alloc(sizeof(*driver) + env_len); + driver = (struct screen_driver *)mem_alloc(sizeof(*driver) + env_len); if (!driver) return NULL; /* These four operations fully initialize *driver. */ diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index f5944536..7c46591f 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -283,7 +283,7 @@ exec_on_master_terminal(struct terminal *term, { int blockh; int param_size = plen + dlen + 2 /* 2 null char */ + 1 /* fg */; - char *param = fmem_alloc(param_size); + char *param = (char *)fmem_alloc(param_size); if (!param) return; @@ -325,7 +325,7 @@ exec_on_slave_terminal( struct terminal *term, enum term_exec fg) { int data_size = plen + dlen + 1 /* 0 */ + 1 /* fg */ + 2 /* 2 null char */; - char *data = fmem_alloc(data_size); + char *data = (char *)fmem_alloc(data_size); if (!data) return; @@ -395,7 +395,7 @@ do_terminal_function(struct terminal *term, unsigned char code, char *data) { int data_len = strlen(data); - char *x_data = fmem_alloc(data_len + 1 /* code */ + 1 /* null char */); + char *x_data = (char *)fmem_alloc(data_len + 1 /* code */ + 1 /* null char */); if (!x_data) return; x_data[0] = code; diff --git a/src/terminal/window.c b/src/terminal/window.c index 02b2ba06..4f120dbb 100644 --- a/src/terminal/window.c +++ b/src/terminal/window.c @@ -165,7 +165,7 @@ empty_window_handler(struct window *win, struct term_event *ev) void add_empty_window(struct terminal *term, void (*fn)(void *), void *data) { - struct ewd *ewd = mem_alloc(sizeof(*ewd)); + struct ewd *ewd = (struct ewd *)mem_alloc(sizeof(*ewd)); if (!ewd) return; ewd->fn = fn; diff --git a/src/util/base64.c b/src/util/base64.c index 09f25242..201b04d1 100644 --- a/src/util/base64.c +++ b/src/util/base64.c @@ -33,7 +33,7 @@ base64_encode_bin(char *in, int inlen, int *outlen) assert(in && *in); if_assert_failed return NULL; - out = outstr = mem_alloc((inlen / 3) * 4 + 4 + 1); + out = outstr = (char *)mem_alloc((inlen / 3) * 4 + 4 + 1); if (!out) return NULL; while (inlen >= 3) { @@ -93,7 +93,7 @@ base64_decode_bin(char *in, int inlen, int *outlen) assert(in && *in); if_assert_failed return NULL; - outstr = out = mem_alloc(inlen / 4 * 3 + 1); + outstr = out = (char *)mem_alloc(inlen / 4 * 3 + 1); if (!outstr) return NULL; if (!once) { diff --git a/src/util/fastfind.c b/src/util/fastfind.c index bab59c5a..64741a9c 100644 --- a/src/util/fastfind.c +++ b/src/util/fastfind.c @@ -386,7 +386,7 @@ static inline void compress_node(struct ff_node *leafset, struct fastfind_info *info, int i, int pos) { - struct ff_node_c *new_ = mem_alloc(sizeof(*new_)); + struct ff_node_c *new_ = (struct ff_node_c *)mem_alloc(sizeof(*new_)); if (!new_) return; diff --git a/src/util/file.c b/src/util/file.c index e4befc85..8fad8c11 100644 --- a/src/util/file.c +++ b/src/util/file.c @@ -154,7 +154,7 @@ get_unique_name(char *fileprefix) digits++; if (file != fileprefix) mem_free(file); - file = mem_alloc(fileprefixlen + 2 + digits); + file = (char *)mem_alloc(fileprefixlen + 2 + digits); if (!file) return NULL; memcpy(file, fileprefix, fileprefixlen); @@ -187,7 +187,7 @@ file_read_line(char *line, size_t *size, FILE *file, int *lineno) size_t offset = 0; if (!line) { - line = mem_alloc(MAX_STR_LEN); + line = (char *)mem_alloc(MAX_STR_LEN); if (!line) return NULL; @@ -395,7 +395,7 @@ mkalldirs(const char *path) /* Make a copy of path, to be able to write to it. Otherwise, the * function is unsafe if called with a read-only char *argument. */ len = strlen(path) + 1; - p = fmem_alloc(len); + p = (char *)fmem_alloc(len); if (!p) return -1; memcpy(p, path, len); diff --git a/src/util/hash.c b/src/util/hash.c index ed3c8060..c0c759ce 100644 --- a/src/util/hash.c +++ b/src/util/hash.c @@ -37,7 +37,7 @@ init_hash(unsigned int width, hash_func_T func) if_assert_failed return NULL; /* One is already reserved in struct hash, so use size - 1. */ - hash = mem_alloc(sizeof(*hash) + (hash_size(width) - 1) + hash = (struct hash *)mem_alloc(sizeof(*hash) + (hash_size(width) - 1) * sizeof(struct list_head)); if (!hash) return NULL; @@ -86,7 +86,7 @@ add_hash_item(struct hash *hash, const char *key, unsigned int keylen, void *value) { hash_value_T hashval; - struct hash_item *item = mem_alloc(sizeof(*item)); + struct hash_item *item = (struct hash_item *)mem_alloc(sizeof(*item)); if (!item) return NULL; diff --git a/src/util/memlist.c b/src/util/memlist.c index fad65dab..c8f8e42c 100644 --- a/src/util/memlist.c +++ b/src/util/memlist.c @@ -52,7 +52,7 @@ getml(void *p, ...) va_end(ap); /* Allocate space for memory list. */ - ml = mem_alloc(ML_SIZE(n)); + ml = (struct memory_list *)mem_alloc(ML_SIZE(n)); if (!ml) return NULL; /* First element. */ @@ -106,7 +106,7 @@ add_to_ml(struct memory_list **ml, ...) if (!*ml) { /* If getml() wasn't called before or returned NULL, * then we create it. */ - *ml = mem_alloc(ML_SIZE(n)); + *ml = (struct memory_list *)mem_alloc(ML_SIZE(n)); if (!*ml) return; (*ml)->n = 0; @@ -147,7 +147,7 @@ add_one_to_ml(struct memory_list **ml, void *p) if (!*ml) { /* If getml() wasn't called before or returned NULL, * then we create it. */ - *ml = mem_alloc(ML_SIZE(1)); + *ml = (struct memory_list *)mem_alloc(ML_SIZE(1)); if (!*ml) return; (*ml)->n = 0; diff --git a/src/util/memory.h b/src/util/memory.h index efbb4cb2..9edae018 100644 --- a/src/util/memory.h +++ b/src/util/memory.h @@ -128,9 +128,9 @@ mem_align_alloc__( oldsize *= objsize; #ifdef DEBUG_MEMLEAK - data = debug_mem_realloc(file, line, *ptr, newsize); + data = (char *)debug_mem_realloc(file, line, *ptr, newsize); #else - data = mem_realloc(*ptr, newsize); + data = (char *)mem_realloc(*ptr, newsize); #endif if (!data) return NULL; @@ -185,9 +185,9 @@ intdup__( int i) { #ifdef DEBUG_MEMLEAK - int *p = debug_mem_alloc(file, line, sizeof(*p)); + int *p = (int *)debug_mem_alloc(file, line, sizeof(*p)); #else - int *p = mem_alloc(sizeof(*p)); + int *p = (int *)mem_alloc(sizeof(*p)); #endif if (p) *p = i; diff --git a/src/util/snprintf.c b/src/util/snprintf.c index 120b0f15..0f9091dc 100644 --- a/src/util/snprintf.c +++ b/src/util/snprintf.c @@ -839,7 +839,7 @@ elinks_vasprintf(char **ptr, const char *format, va_list ap) * allocated by vasprintf to take into account whether the system * vasprintf (and therefore malloc) or our own vasprintf * (and therefore mem_alloc) were used. -- Miciah */ - (*ptr) = (char *) malloc(ret + 1); + (*ptr) = (char *)malloc(ret + 1); if (!*ptr) return -1; va_copy(ap2, ap); diff --git a/src/util/snprintf.h b/src/util/snprintf.h index 9c72a2a0..5d3f1538 100644 --- a/src/util/snprintf.h +++ b/src/util/snprintf.h @@ -91,7 +91,7 @@ vasprintfa(const char *fmt, va_list ap) { return NULL; size = strlen(str1) + 1; - str2 = mem_alloc(size); + str2 = (char *)mem_alloc(size); if (str2) memcpy(str2, str1, size); free(str1); diff --git a/src/util/string.c b/src/util/string.c index 67627696..23633320 100644 --- a/src/util/string.c +++ b/src/util/string.c @@ -49,7 +49,7 @@ debug_memacpy(const char *f, int l, const char *src, int len) string_assert(f, l, len >= 0, "memacpy"); if_assert_failed len = 0; - m = debug_mem_alloc(f, l, len + 1); + m = (char *)debug_mem_alloc(f, l, len + 1); if (!m) return NULL; if (src && len) memcpy(m, src, len); @@ -77,7 +77,7 @@ memacpy(const char *src, int len) assertm(len >= 0, "[memacpy]"); if_assert_failed { len = 0; } - m = mem_alloc(len + 1); + m = (char *)mem_alloc(len + 1); if (!m) return NULL; if (src && len) memcpy(m, src, len); @@ -145,7 +145,7 @@ straconcat(const char *str, ...) if_assert_failed { return NULL; } len = strlen(str); - s = mem_alloc(len + 1); + s = (char *)mem_alloc(len + 1); if (!s) return NULL; if (len) memcpy(s, str, len); @@ -330,9 +330,9 @@ init_string(struct string *string) string->length = 0; #ifdef DEBUG_MEMLEAK - string->source = debug_mem_alloc(file, line, STRING_GRANULARITY + 1); + string->source = (char *)debug_mem_alloc(file, line, STRING_GRANULARITY + 1); #else - string->source = mem_alloc(STRING_GRANULARITY + 1); + string->source = (char *)mem_alloc(STRING_GRANULARITY + 1); #endif if (!string->source) return NULL; @@ -622,7 +622,7 @@ add_to_string_list(LIST_OF(struct string_list_item) *list, assertm(list && source, "[add_to_string_list]"); if_assert_failed return NULL; - item = mem_alloc(sizeof(*item)); + item = (struct string_list_item *)mem_alloc(sizeof(*item)); if (!item) return NULL; string = &item->string; diff --git a/src/viewer/dump/dump.c b/src/viewer/dump/dump.c index 4a812118..faccfc26 100644 --- a/src/viewer/dump/dump.c +++ b/src/viewer/dump/dump.c @@ -173,7 +173,7 @@ dump_output_alloc(int fd, struct string *string, int cp) assert((fd == -1) ^ (string == NULL)); if_assert_failed return NULL; - out = mem_alloc(sizeof(*out)); + out = (struct dump_output *)mem_alloc(sizeof(*out)); if (out) { out->fd = fd; out->string = string; diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index e3a4c9be..dfcd9826 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -79,7 +79,7 @@ init_submitted_value(char *name, char *value, enum form_type type, { struct submitted_value *sv; - sv = mem_alloc(sizeof(*sv)); + sv = (struct submitted_value *)mem_alloc(sizeof(*sv)); if (!sv) return NULL; sv->value = stracpy(value); diff --git a/src/viewer/text/search.c b/src/viewer/text/search.c index 1d99e664..369b2871 100644 --- a/src/viewer/text/search.c +++ b/src/viewer/text/search.c @@ -219,7 +219,7 @@ get_search_data(struct document *document) document->nsearch = 0; - document->search = mem_alloc(n * sizeof(*document->search)); + document->search = (struct search *)mem_alloc(n * sizeof(*document->search)); if (!document->search) return; get_srch(document); @@ -296,7 +296,7 @@ get_search_region_from_search_nodes(struct search *s1, struct search *s2, *doclen = s2 - s1 + pattern_len; if (!*doclen) return NULL; - doc = mem_alloc((*doclen + 1) * sizeof(UCHAR)); + doc = (UCHAR *)mem_alloc((*doclen + 1) * sizeof(UCHAR)); if (!doc) { *doclen = -1; return NULL; @@ -483,7 +483,7 @@ static UCHAR * memacpy_u(char *text, int textlen, int utf8) { #ifdef CONFIG_UTF8 - UCHAR *mem = mem_alloc((textlen + 1) * sizeof(UCHAR)); + UCHAR *mem = (UCHAR *)mem_alloc((textlen + 1) * sizeof(UCHAR)); if (!mem) return NULL; if (utf8) { diff --git a/src/viewer/text/vs.c b/src/viewer/text/vs.c index 1c8a2acf..e54b0896 100644 --- a/src/viewer/text/vs.c +++ b/src/viewer/text/vs.c @@ -120,7 +120,7 @@ copy_vs(struct view_state *dst, struct view_state *src) } if (src->form_info_len) { - dst->form_info = mem_alloc(src->form_info_len + dst->form_info = (struct form_state *)mem_alloc(src->form_info_len * sizeof(*src->form_info)); if (dst->form_info) { int i;