1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-28 01:35:32 +00:00

[mem_calloc] Cast

This commit is contained in:
Witold Filipczyk 2022-01-16 21:08:50 +01:00
parent be8a030fa7
commit 881f896e85
84 changed files with 158 additions and 158 deletions

View File

@ -35,7 +35,7 @@ do_dialog(struct terminal *term, struct dialog *dlg,
{ {
struct dialog_data *dlg_data; struct dialog_data *dlg_data;
dlg_data = mem_calloc(1, sizeof(*dlg_data) + dlg_data = (struct dialog_data *)mem_calloc(1, sizeof(*dlg_data) +
sizeof(struct widget_data) * dlg->number_of_widgets); sizeof(struct widget_data) * dlg->number_of_widgets);
if (!dlg_data) { if (!dlg_data) {
/* Worry not: freeml() checks whether its argument is NULL. */ /* Worry not: freeml() checks whether its argument is NULL. */
@ -741,7 +741,7 @@ refresh_dialog(struct dialog_data *dlg_data, dialog_refresh_handler_T handler, v
struct dialog_refresh *refresh = dlg_data->dlg->refresh; struct dialog_refresh *refresh = dlg_data->dlg->refresh;
if (!refresh) { if (!refresh) {
refresh = mem_calloc(1, sizeof(*refresh)); refresh = (struct dialog_refresh *)mem_calloc(1, sizeof(*refresh));
if (!refresh) return; if (!refresh) return;
dlg_data->dlg->refresh = refresh; dlg_data->dlg->refresh = refresh;

View File

@ -47,7 +47,7 @@ add_listbox_item(struct hierbox_browser *browser, struct listbox_item *root,
root = &browser->root; root = &browser->root;
} }
item = mem_calloc(1, sizeof(*item)); item = (struct listbox_item *)mem_calloc(1, sizeof(*item));
if (!item) return NULL; if (!item) return NULL;
init_list(item->child); init_list(item->child);
@ -375,7 +375,7 @@ init_listbox_context(struct listbox_data *box, struct terminal *term,
{ {
struct listbox_context *context; struct listbox_context *context;
context = mem_calloc(1, sizeof(*context)); context = (struct listbox_context *)mem_calloc(1, sizeof(*context));
if (!context) return NULL; if (!context) return NULL;
context->item = item; context->item = item;

View File

@ -111,7 +111,7 @@ void
do_menu_selected(struct terminal *term, struct menu_item *items, do_menu_selected(struct terminal *term, struct menu_item *items,
void *data, int selected, int hotkeys) void *data, int selected, int hotkeys)
{ {
struct menu *menu = mem_calloc(1, sizeof(*menu)); struct menu *menu = (struct menu *)mem_calloc(1, sizeof(*menu));
if (menu) { if (menu) {
menu->selected = selected; menu->selected = selected;
@ -1042,7 +1042,7 @@ do_mainmenu(struct terminal *term, struct menu_item *items,
struct window *win; struct window *win;
if (!term->main_menu) { if (!term->main_menu) {
term->main_menu = mem_calloc(1, sizeof(*menu)); term->main_menu = (struct menu *)mem_calloc(1, sizeof(*menu));
if (!term->main_menu) return; if (!term->main_menu) return;
init = 1; init = 1;
} }

View File

@ -77,7 +77,7 @@ get_bfu_color(struct terminal *term, char *stylename)
opt = get_opt_rec_real(opt, stylename); opt = get_opt_rec_real(opt, stylename);
if (!opt) return NULL; if (!opt) return NULL;
entry = mem_calloc(1, sizeof(*entry)); entry = (struct bfu_color_entry *)mem_calloc(1, sizeof(*entry));
if (!entry) return NULL; if (!entry) return NULL;
item = add_hash_item(bfu_colors, stylename, stylenamelen, entry); item = add_hash_item(bfu_colors, stylename, stylenamelen, entry);

View File

@ -275,7 +275,7 @@ on_element_open(void *data, const char *name, const char **attr)
} }
for (; *attr; attr += 2) { for (; *attr; attr += 2) {
struct attributes *attribute = mem_calloc(1, sizeof(*attribute)); struct attributes *attribute = (struct attributes *)mem_calloc(1, sizeof(*attribute));
char *name = stracpy((char *) attr[0]); char *name = stracpy((char *) attr[0]);
char *value = stracpy((char *) attr[1]); char *value = stracpy((char *) attr[1]);
@ -508,7 +508,7 @@ new_node(struct tree_node *parent)
{ {
struct tree_node *node; struct tree_node *node;
node = mem_calloc(1, sizeof(*node)); node = (struct tree_node *)mem_calloc(1, sizeof(*node));
if (!node) return NULL; if (!node) return NULL;
node->parent = parent ? parent : node; node->parent = parent ? parent : node;

View File

@ -309,7 +309,7 @@ init_bookmark(struct bookmark *root, char *title, char *url)
{ {
struct bookmark *bm; struct bookmark *bm;
bm = mem_calloc(1, sizeof(*bm)); bm = (struct bookmark *)mem_calloc(1, sizeof(*bm));
if (!bm) return NULL; if (!bm) return NULL;
bm->title = stracpy(title); bm->title = stracpy(title);

2
src/cache/cache.c vendored
View File

@ -134,7 +134,7 @@ get_cache_entry(struct uri *uri)
shrink_memory(0); shrink_memory(0);
cached = mem_calloc(1, sizeof(*cached)); cached = (struct cache_entry *)mem_calloc(1, sizeof(*cached));
if (!cached) return NULL; if (!cached) return NULL;
cached->uri = get_proxied_uri(uri); cached->uri = get_proxied_uri(uri);

View File

@ -861,7 +861,7 @@ push_kbdbind_add_button(struct dialog_data *dlg_data,
return EVENT_PROCESSED; return EVENT_PROCESSED;
} }
hop = mem_calloc(1, sizeof(*hop)); hop = (struct kbdbind_add_hop *)mem_calloc(1, sizeof(*hop));
if (!hop) return EVENT_PROCESSED; if (!hop) return EVENT_PROCESSED;
hop->term = term; hop->term = term;
hop->widget_data = dlg_data->widgets_data; hop->widget_data = dlg_data->widgets_data;

View File

@ -106,7 +106,7 @@ add_keybinding(enum keymap_id keymap_id, action_id_T action_id,
is_default = (delete_keybinding(keymap_id, kbd) == 2); is_default = (delete_keybinding(keymap_id, kbd) == 2);
keybinding = mem_calloc(1, sizeof(*keybinding)); keybinding = (struct keybinding *)mem_calloc(1, sizeof(*keybinding));
if (!keybinding) return NULL; if (!keybinding) return NULL;
keybinding->keymap_id = keymap_id; keybinding->keymap_id = keymap_id;

View File

@ -494,7 +494,7 @@ add_opt_rec(struct option *tree, char *path, struct option *option)
static inline struct listbox_item * static inline struct listbox_item *
init_option_listbox_item(struct option *option) init_option_listbox_item(struct option *option)
{ {
struct listbox_item *item = mem_calloc(1, sizeof(*item)); struct listbox_item *item = (struct listbox_item *)mem_calloc(1, sizeof(*item));
if (!item) return NULL; if (!item) return NULL;
@ -512,7 +512,7 @@ add_opt(struct option *tree, char *path, char *capt,
char *name, enum option_flags flags, enum option_type type, char *name, enum option_flags flags, enum option_type type,
long min, long max, longptr_T value, char *desc) long min, long max, longptr_T value, char *desc)
{ {
struct option *option = mem_calloc(1, sizeof(*option)); struct option *option = (struct option *)mem_calloc(1, sizeof(*option));
if (!option) return NULL; if (!option) return NULL;
@ -678,7 +678,7 @@ delete_option(struct option *option)
struct option * struct option *
copy_option(struct option *template_, int flags) copy_option(struct option *template_, int flags)
{ {
struct option *option = mem_calloc(1, sizeof(*option)); struct option *option = (struct option *)mem_calloc(1, sizeof(*option));
if (!option) return NULL; if (!option) return NULL;

View File

@ -159,7 +159,7 @@ get_cookie_server(char *host, int hostlen)
return cs; return cs;
} }
cs = mem_calloc(1, sizeof(*cs) + hostlen); cs = (struct cookie_server *)mem_calloc(1, sizeof(*cs) + hostlen);
if (!cs) return NULL; if (!cs) return NULL;
memcpy(cs->host, host, hostlen); memcpy(cs->host, host, hostlen);
@ -312,7 +312,7 @@ init_cookie(char *name, char *value,
char *path, char *domain, char *path, char *domain,
struct cookie_server *server) struct cookie_server *server)
{ {
struct cookie *cookie = mem_calloc(1, sizeof(*cookie)); struct cookie *cookie = (struct cookie *)mem_calloc(1, sizeof(*cookie));
if (!cookie || !name || !value || !path || !domain || !server) { if (!cookie || !name || !value || !path || !domain || !server) {
mem_free_if(cookie); mem_free_if(cookie);
@ -754,7 +754,7 @@ load_cookies(void) {
} }
/* Prepare cookie if all members and fields was read. */ /* Prepare cookie if all members and fields was read. */
cookie = mem_calloc(1, sizeof(*cookie)); cookie = (struct cookie *)mem_calloc(1, sizeof(*cookie));
if (!cookie) continue; if (!cookie) continue;
cookie->server = get_cookie_server(members[SERVER].pos, members[SERVER].len); cookie->server = get_cookie_server(members[SERVER].pos, members[SERVER].len);

View File

@ -90,7 +90,7 @@ menu_keys(struct terminal *term, void *d_, void *xxx)
struct string keys; struct string keys;
struct keys_toggle_info *info; struct keys_toggle_info *info;
info = mem_calloc(1, sizeof(*info)); info = (struct keys_toggle_info *)mem_calloc(1, sizeof(*info));
if (!info || !init_string(&keys)) { if (!info || !init_string(&keys)) {
mem_free_if(info); mem_free_if(info);

View File

@ -77,7 +77,7 @@ css_parse_properties(LIST_OF(struct css_property) *props,
/* We might be on track of something, cook up the struct. */ /* We might be on track of something, cook up the struct. */
prop = mem_calloc(1, sizeof(*prop)); prop = (struct css_property *)mem_calloc(1, sizeof(*prop));
if (!prop) { if (!prop) {
goto ride_on; goto ride_on;
} }
@ -457,7 +457,7 @@ css_parse_selector(struct css_stylesheet *css, struct scanner *scanner,
last_token.string, last_token.length); last_token.string, last_token.length);
if (!selector) continue; if (!selector) continue;
pkg = mem_calloc(1, sizeof(*pkg)); pkg = (struct selector_pkg *)mem_calloc(1, sizeof(*pkg));
if (!pkg) continue; if (!pkg) continue;
add_to_list(*selectors, pkg); add_to_list(*selectors, pkg);
pkg->selector = selector; pkg->selector = selector;

View File

@ -54,7 +54,7 @@ init_css_selector(struct css_selector_set *sels,
{ {
struct css_selector *selector; struct css_selector *selector;
selector = mem_calloc(1, sizeof(*selector)); selector = (struct css_selector *)mem_calloc(1, sizeof(*selector));
if (!selector) return NULL; if (!selector) return NULL;
selector->relation = relation; selector->relation = relation;
@ -263,7 +263,7 @@ init_css_stylesheet(css_stylesheet_importer_T importer, void *import_data)
{ {
struct css_stylesheet *css; struct css_stylesheet *css;
css = mem_calloc(1, sizeof(*css)); css = (struct css_stylesheet *)mem_calloc(1, sizeof(*css));
if (!css) if (!css)
return NULL; return NULL;
css->import = importer; css->import = importer;

View File

@ -134,7 +134,7 @@ get_ip(struct document *document)
struct document * struct document *
init_document(struct cache_entry *cached, struct document_options *options) init_document(struct cache_entry *cached, struct document_options *options)
{ {
struct document *document = mem_calloc(1, sizeof(*document)); struct document *document = (struct document *)mem_calloc(1, sizeof(*document));
if (!document) return NULL; if (!document) return NULL;

View File

@ -189,8 +189,8 @@ dom_rss_push_document(struct dom_stack *stack, struct dom_node *root, void *xxx)
css_parse_stylesheet(css, NULL, styles, styles + sizeof(default_colors)); css_parse_stylesheet(css, NULL, styles, styles + sizeof(default_colors));
} }
} }
renderer->data = (void *)mem_calloc(1, sizeof(*rss));
rss = renderer->data = mem_calloc(1, sizeof(*rss)); rss = (struct rss_renderer *)renderer->data;
if (!rss) if (!rss)
return DOM_CODE_ALLOC_ERR; return DOM_CODE_ALLOC_ERR;

View File

@ -357,8 +357,8 @@ render_dom_document_start(struct dom_stack *stack, struct dom_node *node, void *
default_colors + sizeof(default_colors)); default_colors + sizeof(default_colors));
} }
} }
renderer->data = (void *)mem_calloc(1, sizeof(*data));
data = renderer->data = mem_calloc(1, sizeof(*data)); data = (struct source_renderer *)renderer->data;
/* Initialize styles for all the DOM node types. */ /* Initialize styles for all the DOM node types. */

View File

@ -71,7 +71,7 @@ form_type2str(enum form_type num)
struct form * struct form *
init_form(void) init_form(void)
{ {
struct form *form = mem_calloc(1, sizeof(*form)); struct form *form = (struct form *)mem_calloc(1, sizeof(*form));
if (!form) return NULL; if (!form) return NULL;

View File

@ -81,7 +81,7 @@ create_frameset(struct frameset_param *fp)
size = fp->x * fp->y; size = fp->x * fp->y;
/* size - 1 since one struct frame_desc is already reserved /* size - 1 since one struct frame_desc is already reserved
* in struct frameset_desc. */ * in struct frameset_desc. */
fd = mem_calloc(1, sizeof(*fd) fd = (struct frameset_desc *)mem_calloc(1, sizeof(*fd)
+ (size - 1) * sizeof(fd->frame_desc[0])); + (size - 1) * sizeof(fd->frame_desc[0]));
if (!fd) return NULL; if (!fd) return NULL;
@ -145,7 +145,7 @@ find_fd(struct session *ses, char *name,
return doc_view; return doc_view;
} }
doc_view = mem_calloc(1, sizeof(*doc_view)); doc_view = (struct document_view *)mem_calloc(1, sizeof(*doc_view));
if (!doc_view) return NULL; if (!doc_view) return NULL;
doc_view->used = 1; doc_view->used = 1;

View File

@ -100,7 +100,7 @@ find_ifd(struct session *ses, char *name,
return doc_view; return doc_view;
} }
doc_view = mem_calloc(1, sizeof(*doc_view)); doc_view = (struct document_view *)mem_calloc(1, sizeof(*doc_view));
if (!doc_view) return NULL; if (!doc_view) return NULL;
doc_view->used = 1; doc_view->used = 1;

View File

@ -669,7 +669,7 @@ get_image_map(char *head, char *pos, char *eof,
ct = get_convert_table(hd.source, to, def, NULL, NULL, hdef); ct = get_convert_table(hd.source, to, def, NULL, NULL, hdef);
done_string(&hd); done_string(&hd);
*menu = mem_calloc(1, sizeof(**menu)); *menu = (struct menu_item *)mem_calloc(1, sizeof(**menu));
if (!*menu) return -1; if (!*menu) return -1;
while (look_for_map(&pos, eof, uri, options)); while (look_for_map(&pos, eof, uri, options));
@ -769,7 +769,7 @@ init_html_parser(struct uri *uri, struct document_options *options,
assert(uri && options); assert(uri && options);
if_assert_failed return NULL; if_assert_failed return NULL;
html_context = mem_calloc(1, sizeof(*html_context)); html_context = (struct html_context *)mem_calloc(1, sizeof(*html_context));
if (!html_context) return NULL; if (!html_context) return NULL;
#ifdef CONFIG_CSS #ifdef CONFIG_CSS
@ -794,7 +794,7 @@ init_html_parser(struct uri *uri, struct document_options *options,
* should use the document charset instead. */ * should use the document charset instead. */
scan_http_equiv(start, end, head, title, options->cp); scan_http_equiv(start, end, head, title, options->cp);
e = mem_calloc(1, sizeof(*e)); e = (struct html_element *)mem_calloc(1, sizeof(*e));
if (!e) return NULL; if (!e) return NULL;
add_to_list(html_context->stack, e); add_to_list(html_context->stack, e);

View File

@ -129,7 +129,7 @@ init_form_control(enum form_type type, char *attr,
{ {
struct el_form_control *fc; struct el_form_control *fc;
fc = mem_calloc(1, sizeof(*fc)); fc = (struct el_form_control *)mem_calloc(1, sizeof(*fc));
if (!fc) return NULL; if (!fc) return NULL;
fc->type = type; fc->type = type;
@ -475,7 +475,7 @@ end_parse:
*end = en; *end = en;
if (!order) goto abort; if (!order) goto abort;
labels = mem_calloc(order, sizeof(char *)); labels = (char **)mem_calloc(order, sizeof(char *));
if (!labels) goto abort; if (!labels) goto abort;
fc = init_form_control(FC_SELECT, attr, html_context); fc = init_form_control(FC_SELECT, attr, html_context);

View File

@ -253,11 +253,11 @@ parse_table_attributes(struct table *table, char *attr, int real,
struct table * struct table *
new_table(void) new_table(void)
{ {
struct table *table = mem_calloc(1, sizeof(*table)); struct table *table = (struct table *)mem_calloc(1, sizeof(*table));
if (!table) return NULL; if (!table) return NULL;
table->cells = mem_calloc(INIT_REAL_COLS * INIT_REAL_ROWS, table->cells = (struct table_cell *)mem_calloc(INIT_REAL_COLS * INIT_REAL_ROWS,
sizeof(*table->cells)); sizeof(*table->cells));
if (!table->cells) { if (!table->cells) {
mem_free(table); mem_free(table);
@ -266,7 +266,7 @@ new_table(void)
table->real_cols = INIT_REAL_COLS; table->real_cols = INIT_REAL_COLS;
table->real_rows = INIT_REAL_ROWS; table->real_rows = INIT_REAL_ROWS;
table->columns = mem_calloc(INIT_REAL_COLS, sizeof(*table->columns)); table->columns = (struct table_column *)mem_calloc(INIT_REAL_COLS, sizeof(*table->columns));
if (!table->columns) { if (!table->columns) {
mem_free(table->cells); mem_free(table->cells);
mem_free(table); mem_free(table);
@ -421,7 +421,7 @@ new_cell(struct table *table, int dest_col, int dest_row)
sizeof(*new_.cells), limit); sizeof(*new_.cells), limit);
if (!new_.real_rows) return NULL; if (!new_.real_rows) return NULL;
new_.cells = mem_calloc(new_.real_cols * new_.real_rows, new_.cells = (struct table_cell *)mem_calloc(new_.real_cols * new_.real_rows,
sizeof(*new_.cells)); sizeof(*new_.cells));
if (!new_.cells) return NULL; if (!new_.cells) return NULL;
@ -912,7 +912,7 @@ scan_done:
} }
if (table->rows) { if (table->rows) {
table->rows_heights = mem_calloc(table->rows, sizeof(*table->rows_heights)); table->rows_heights = (int *)mem_calloc(table->rows, sizeof(*table->rows_heights));
if (!table->rows_heights) if (!table->rows_heights)
goto abort; goto abort;
} else { } else {

View File

@ -1397,7 +1397,7 @@ align_line(struct html_context *html_context, int y, int last)
static inline void static inline void
init_link_event_hooks(struct html_context *html_context, struct link *link) init_link_event_hooks(struct html_context *html_context, struct link *link)
{ {
link->event_hooks = mem_calloc(1, sizeof(*link->event_hooks)); link->event_hooks = (LIST_OF(struct script_event_hook) *)mem_calloc(1, sizeof(*link->event_hooks));
if (!link->event_hooks) return; if (!link->event_hooks) return;
#define add_evhook(list_, type_, src_) \ #define add_evhook(list_, type_, src_) \
@ -1406,7 +1406,7 @@ init_link_event_hooks(struct html_context *html_context, struct link *link)
\ \
if (!src_) break; \ if (!src_) break; \
\ \
evhook = mem_calloc(1, sizeof(*evhook)); \ evhook = (struct script_event_hook *)mem_calloc(1, sizeof(*evhook)); \
if (!evhook) break; \ if (!evhook) break; \
\ \
evhook->type = type_; \ evhook->type = type_; \
@ -2468,7 +2468,7 @@ format_html_part(struct html_context *html_context,
done_link_state_info(); done_link_state_info();
renderer_context.nobreak = 1; renderer_context.nobreak = 1;
part = mem_calloc(1, sizeof(*part)); part = (struct part *)mem_calloc(1, sizeof(*part));
if (!part) goto ret; if (!part) goto ret;
part->document = document; part->document = document;
@ -2513,7 +2513,7 @@ ret:
/* Create a new entry. */ /* Create a new entry. */
/* Clear memory to prevent bad key comparaison due to alignment /* Clear memory to prevent bad key comparaison due to alignment
* of key fields. */ * of key fields. */
struct table_cache_entry *tce = mem_calloc(1, sizeof(*tce)); struct table_cache_entry *tce = (struct table_cache_entry *)mem_calloc(1, sizeof(*tce));
if (tce) { if (tce) {
tce->key.start = start; tce->key.start = start;

View File

@ -258,12 +258,12 @@ get_column_widths(struct table *table)
if (!table->cols) return -1; /* prevents calloc(0, ...) calls */ if (!table->cols) return -1; /* prevents calloc(0, ...) calls */
if (!table->min_cols_widths) { if (!table->min_cols_widths) {
table->min_cols_widths = mem_calloc(table->cols, sizeof(*table->min_cols_widths)); table->min_cols_widths = (int *)mem_calloc(table->cols, sizeof(*table->min_cols_widths));
if (!table->min_cols_widths) return -1; if (!table->min_cols_widths) return -1;
} }
if (!table->max_cols_widths) { if (!table->max_cols_widths) {
table->max_cols_widths = mem_calloc(table->cols, sizeof(*table->max_cols_widths)); table->max_cols_widths = (int *)mem_calloc(table->cols, sizeof(*table->max_cols_widths));
if (!table->max_cols_widths) { if (!table->max_cols_widths) {
mem_free_set(&table->min_cols_widths, NULL); mem_free_set(&table->min_cols_widths, NULL);
return -1; return -1;
@ -271,7 +271,7 @@ get_column_widths(struct table *table)
} }
if (!table->cols_widths) { if (!table->cols_widths) {
table->cols_widths = mem_calloc(table->cols, sizeof(*table->cols_widths)); table->cols_widths = (int *)mem_calloc(table->cols, sizeof(*table->cols_widths));
if (!table->cols_widths) { if (!table->cols_widths) {
mem_free_set(&table->min_cols_widths, NULL); mem_free_set(&table->min_cols_widths, NULL);
mem_free_set(&table->max_cols_widths, NULL); mem_free_set(&table->max_cols_widths, NULL);
@ -582,7 +582,7 @@ check_table_widths(struct html_context *html_context, struct table *table)
int colspan; int colspan;
int width, new_width; int width, new_width;
int max, max_index = 0; /* go away, warning! */ int max, max_index = 0; /* go away, warning! */
int *widths = mem_calloc(table->cols, sizeof(*widths)); int *widths = (int *)mem_calloc(table->cols, sizeof(*widths));
if (!widths) return; if (!widths) return;

View File

@ -470,7 +470,7 @@ render_document_frames(struct session *ses, int no_cache)
struct view_state *vs = NULL; struct view_state *vs = NULL;
if (!ses->doc_view) { if (!ses->doc_view) {
ses->doc_view = mem_calloc(1, sizeof(*ses->doc_view)); ses->doc_view = (struct document_view *)mem_calloc(1, sizeof(*ses->doc_view));
if (!ses->doc_view) return; if (!ses->doc_view) return;
ses->doc_view->session = ses; ses->doc_view->session = ses;
ses->doc_view->search_word = &ses->search_word; ses->doc_view->search_word = &ses->search_word;
@ -579,10 +579,10 @@ sort_links(struct document *document)
if (!document->height) return; if (!document->height) return;
mem_free_if(document->lines1); mem_free_if(document->lines1);
document->lines1 = mem_calloc(document->height, sizeof(*document->lines1)); document->lines1 = (struct link **)mem_calloc(document->height, sizeof(*document->lines1));
mem_free_if(document->lines2); mem_free_if(document->lines2);
if (!document->lines1) return; if (!document->lines1) return;
document->lines2 = mem_calloc(document->height, sizeof(*document->lines2)); document->lines2 = (struct link **)mem_calloc(document->height, sizeof(*document->lines2));
if (!document->lines2) { if (!document->lines2) {
mem_free(document->lines1); mem_free(document->lines1);
return; return;

View File

@ -804,7 +804,7 @@ scan_done:
} }
if (table->rows) { if (table->rows) {
table->rows_heights = mem_calloc(table->rows, sizeof(*table->rows_heights)); table->rows_heights = (int *)mem_calloc(table->rows, sizeof(*table->rows_heights));
if (!table->rows_heights) if (!table->rows_heights)
goto abort; goto abort;
} else { } else {

View File

@ -219,7 +219,7 @@ tags_init_form_control(enum form_type type, void *node,
{ {
struct el_form_control *fc; struct el_form_control *fc;
fc = mem_calloc(1, sizeof(*fc)); fc = (struct el_form_control *)mem_calloc(1, sizeof(*fc));
if (!fc) return NULL; if (!fc) return NULL;
fc->type = type; fc->type = type;
@ -3485,7 +3485,7 @@ do_tags_html_select(struct source_renderer *renderer, void *node, unsigned char
return; return;
} }
labels = mem_calloc(order, sizeof(unsigned char *)); labels = (unsigned char **)mem_calloc(order, sizeof(unsigned char *));
if (!labels) { if (!labels) {
if (lbl.source) done_string(&lbl); if (lbl.source) done_string(&lbl);
if (orig_lbl.source) done_string(&orig_lbl); if (orig_lbl.source) done_string(&orig_lbl);

View File

@ -359,9 +359,9 @@ init_dom_node_at(
struct dom_string *string, int allocated) struct dom_string *string, int allocated)
{ {
#ifdef DEBUG_MEMLEAK #ifdef DEBUG_MEMLEAK
struct dom_node *node = debug_mem_calloc(file, line, 1, sizeof(*node)); struct dom_node *node = (struct dom_node *)debug_mem_calloc(file, line, 1, sizeof(*node));
#else #else
struct dom_node *node = mem_calloc(1, sizeof(*node)); struct dom_node *node = (struct dom_node *)mem_calloc(1, sizeof(*node));
#endif #endif
if (!node) return NULL; if (!node) return NULL;

View File

@ -478,7 +478,7 @@ parse_dom_select(struct dom_select *select, struct dom_stack *stack,
if (sel.node.type == DOM_NODE_UNKNOWN) if (sel.node.type == DOM_NODE_UNKNOWN)
continue; continue;
select_node = mem_calloc(1, sizeof(*select_node)); select_node = (struct dom_select_node *)mem_calloc(1, sizeof(*select_node));
copy_struct(select_node, &sel); copy_struct(select_node, &sel);
if (!dom_stack_is_empty(stack)) { if (!dom_stack_is_empty(stack)) {
@ -527,7 +527,7 @@ parse_dom_select(struct dom_select *select, struct dom_stack *stack,
struct dom_select * struct dom_select *
init_dom_select(enum dom_select_syntax syntax, struct dom_string *string) init_dom_select(enum dom_select_syntax syntax, struct dom_string *string)
{ {
struct dom_select *select = mem_calloc(1, sizeof(select)); struct dom_select *select = (struct dom_select *)mem_calloc(1, sizeof(select));
struct dom_stack stack; struct dom_stack stack;
enum dom_code code; enum dom_code code;

View File

@ -686,7 +686,7 @@ init_sgml_parser(enum sgml_parser_type type, enum sgml_document_type doctype,
struct sgml_parser *parser; struct sgml_parser *parser;
enum dom_stack_flag stack_flags = 0; enum dom_stack_flag stack_flags = 0;
parser = mem_calloc(1, sizeof(*parser)); parser = (struct sgml_parser *)mem_calloc(1, sizeof(*parser));
if (!parser) return NULL; if (!parser) return NULL;
if (!init_dom_string(&parser->uri, uri->string, uri->length)) { if (!init_dom_string(&parser->uri, uri->string, uri->length)) {

View File

@ -87,7 +87,7 @@ add_dom_stack_context(struct dom_stack *stack, void *data,
if (!realloc_dom_stack_context(&stack->contexts, stack->contexts_size)) if (!realloc_dom_stack_context(&stack->contexts, stack->contexts_size))
return NULL; return NULL;
context = mem_calloc(1, sizeof(*context)); context = (struct dom_stack_context *)mem_calloc(1, sizeof(*context));
if (!context) if (!context)
return NULL; return NULL;

View File

@ -223,7 +223,7 @@ ecmascript_get_interpreter(struct view_state *vs)
assert(vs); assert(vs);
interpreter = mem_calloc(1, sizeof(*interpreter)); interpreter = (struct ecmascript_interpreter *)mem_calloc(1, sizeof(*interpreter));
if (!interpreter) if (!interpreter)
return NULL; return NULL;
@ -312,7 +312,7 @@ check_for_rerender(struct ecmascript_interpreter *interpreter, const char* text)
if (document->dom) { if (document->dom) {
interpreter->changed = false; interpreter->changed = false;
struct delayed_rel *rel = mem_calloc(1, sizeof(*rel)); struct delayed_rel *rel = (struct delayed_rel *)mem_calloc(1, sizeof(*rel));
if (rel) { if (rel) {
rel->cached = cached; rel->cached = cached;
@ -768,7 +768,7 @@ location_goto(struct document_view *doc_view, char *url)
mem_free(new_abs_url); mem_free(new_abs_url);
if (!new_uri) if (!new_uri)
return; return;
deg = mem_calloc(1, sizeof(*deg)); deg = (struct delayed_goto *)mem_calloc(1, sizeof(*deg));
if (!deg) { if (!deg) {
done_uri(new_uri); done_uri(new_uri);
return; return;

View File

@ -153,7 +153,7 @@ js_window_open(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *ar
JSValue ret; JSValue ret;
if (frame && *frame && c_strcasecmp(frame, "_blank")) { if (frame && *frame && c_strcasecmp(frame, "_blank")) {
struct delayed_open *deo = mem_calloc(1, sizeof(*deo)); struct delayed_open *deo = (struct delayed_open *)mem_calloc(1, sizeof(*deo));
if (deo) { if (deo) {
deo->ses = ses; deo->ses = ses;
@ -175,7 +175,7 @@ js_window_open(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *ar
} else { } else {
/* When opening a new tab, we might get rerendered, losing our /* When opening a new tab, we might get rerendered, losing our
* context and triggerring a disaster, so postpone that. */ * context and triggerring a disaster, so postpone that. */
struct delayed_open *deo = mem_calloc(1, sizeof(*deo)); struct delayed_open *deo = (struct delayed_open *)mem_calloc(1, sizeof(*deo));
if (deo) { if (deo) {
deo->ses = ses; deo->ses = ses;

View File

@ -367,7 +367,7 @@ window_open(JSContext *ctx, unsigned int argc, JS::Value *rval)
} }
if (frame && *frame && c_strcasecmp(frame, "_blank")) { if (frame && *frame && c_strcasecmp(frame, "_blank")) {
struct delayed_open *deo = mem_calloc(1, sizeof(*deo)); struct delayed_open *deo = (struct delayed_open *)mem_calloc(1, sizeof(*deo));
if (deo) { if (deo) {
deo->ses = ses; deo->ses = ses;
@ -389,7 +389,7 @@ window_open(JSContext *ctx, unsigned int argc, JS::Value *rval)
} else { } else {
/* When opening a new tab, we might get rerendered, losing our /* When opening a new tab, we might get rerendered, losing our
* context and triggerring a disaster, so postpone that. */ * context and triggerring a disaster, so postpone that. */
struct delayed_open *deo = mem_calloc(1, sizeof(*deo)); struct delayed_open *deo = (struct delayed_open *)mem_calloc(1, sizeof(*deo));
if (deo) { if (deo) {
deo->ses = ses; deo->ses = ses;

View File

@ -43,7 +43,7 @@ struct br_enc_data {
static int static int
brotli_open(struct stream_encoded *stream, int fd) brotli_open(struct stream_encoded *stream, int fd)
{ {
struct br_enc_data *data = mem_calloc(1, sizeof(*data)); struct br_enc_data *data = (struct br_enc_data *)mem_calloc(1, sizeof(*data));
stream->data = NULL; stream->data = NULL;
if (!data) { if (!data) {

View File

@ -36,7 +36,7 @@ struct zstd_enc_data {
static int static int
zstd_open(struct stream_encoded *stream, int fd) zstd_open(struct stream_encoded *stream, int fd)
{ {
struct zstd_enc_data *data = mem_calloc(1, sizeof(*data)); struct zstd_enc_data *data = (struct zstd_enc_data *)mem_calloc(1, sizeof(*data));
stream->data = NULL; stream->data = NULL;
if (!data) { if (!data) {

View File

@ -50,7 +50,7 @@ new_formhist_item(char *url)
struct formhist_data *form; struct formhist_data *form;
int url_len = strlen(url); int url_len = strlen(url);
form = mem_calloc(1, sizeof(*form) + url_len); form = (struct formhist_data *)mem_calloc(1, sizeof(*form) + url_len);
if (!form) return NULL; if (!form) return NULL;
memcpy(form->url, url, url_len); memcpy(form->url, url, url_len);

View File

@ -185,7 +185,7 @@ init_global_history_item(char *url, char *title, time_t vtime)
{ {
struct global_history_item *history_item; struct global_history_item *history_item;
history_item = mem_calloc(1, sizeof(*history_item)); history_item = (struct global_history_item *)mem_calloc(1, sizeof(*history_item));
if (!history_item) if (!history_item)
return NULL; return NULL;

View File

@ -867,7 +867,7 @@ add_utf8(struct conv_table *ct, unicode_val_T u, const char *str)
assertm(ct[*p].u.str == no_str, "bad utf encoding #1"); assertm(ct[*p].u.str == no_str, "bad utf encoding #1");
if_assert_failed return; if_assert_failed return;
nct = mem_calloc(256, sizeof(*nct)); nct = (struct conv_table *)mem_calloc(256, sizeof(*nct));
if (!nct) return; if (!nct) return;
new_translation_table(nct); new_translation_table(nct);
ct[*p].t = 1; ct[*p].t = 1;

View File

@ -177,7 +177,7 @@ get_address(struct socket_info *info, enum addr_type type)
goto free_and_error; goto free_and_error;
} }
addr = mem_calloc(1, sizeof(*addr)); addr = (struct sockaddr_un *)mem_calloc(1, sizeof(*addr));
if (!addr) goto free_and_error; if (!addr) goto free_and_error;
memcpy(addr->sun_path, path.source, path.length); /* ending '\0' is done by calloc() */ memcpy(addr->sun_path, path.source, path.length); /* ending '\0' is done by calloc() */
@ -211,7 +211,7 @@ alloc_address(struct socket_info *info)
if_assert_failed return 0; if_assert_failed return 0;
/* calloc() is safer there. */ /* calloc() is safer there. */
sa = mem_calloc(1, sizeof(*sa)); sa = (struct sockaddr_un *)mem_calloc(1, sizeof(*sa));
if (!sa) return 0; if (!sa) return 0;
info->addr = (struct sockaddr *) sa; info->addr = (struct sockaddr *) sa;
@ -262,7 +262,7 @@ get_address(struct socket_info *info, enum addr_type type)
if (port < IPPORT_USERRESERVED) if (port < IPPORT_USERRESERVED)
return -1; /* Just in case of... */ return -1; /* Just in case of... */
sin = mem_calloc(1, sizeof(*sin)); sin = (struct sockaddr_in *)mem_calloc(1, sizeof(*sin));
if (!sin) return -1; if (!sin) return -1;
sin->sin_family = AF_INET; sin->sin_family = AF_INET;
@ -284,7 +284,7 @@ alloc_address(struct socket_info *info)
if_assert_failed return 0; if_assert_failed return 0;
/* calloc() is safer there. */ /* calloc() is safer there. */
sa = mem_calloc(1, sizeof(*sa)); sa = (struct sockaddr_in *)mem_calloc(1, sizeof(*sa));
if (!sa) return 0; if (!sa) return 0;
info->addr = (struct sockaddr *) sa; info->addr = (struct sockaddr *) sa;

View File

@ -111,7 +111,7 @@ init_mime_handler(char *program, char *description,
int programlen = strlen(program); int programlen = strlen(program);
struct mime_handler *handler; struct mime_handler *handler;
handler = mem_calloc(1, sizeof(*handler) + programlen); handler = (struct mime_handler *)mem_calloc(1, sizeof(*handler) + programlen);
if (!handler) return NULL; if (!handler) return NULL;
memcpy(handler->program, program, programlen); memcpy(handler->program, program, programlen);

View File

@ -152,7 +152,7 @@ init_mailcap_entry(char *command, int priority)
struct mailcap_entry *entry; struct mailcap_entry *entry;
int commandlen = strlen(command); int commandlen = strlen(command);
entry = mem_calloc(1, sizeof(*entry) + commandlen); entry = (struct mailcap_entry *)mem_calloc(1, sizeof(*entry) + commandlen);
if (!entry) return NULL; if (!entry) return NULL;
memcpy(entry->command, command, commandlen); memcpy(entry->command, command, commandlen);

View File

@ -110,7 +110,7 @@ parse_mimetypes_extensions(char *token, char *ctype)
item = get_hash_item(mimetypes_map, extension, extlen); item = get_hash_item(mimetypes_map, extension, extlen);
if (item) continue; if (item) continue;
entry = mem_calloc(1, sizeof(*entry) + extlen); entry = (struct mimetypes_entry *)mem_calloc(1, sizeof(*entry) + extlen);
if (!entry) continue; if (!entry) continue;
entry->content_type = memacpy(ctype, ctypelen); entry->content_type = memacpy(ctype, ctypelen);

View File

@ -179,7 +179,7 @@ add_host_connection(struct connection *conn)
struct host_connection *host_conn = get_host_connection(conn); struct host_connection *host_conn = get_host_connection(conn);
if (!host_conn && conn->uri->host) { if (!host_conn && conn->uri->host) {
host_conn = mem_calloc(1, sizeof(*host_conn)); host_conn = (struct host_connection *)mem_calloc(1, sizeof(*host_conn));
if (!host_conn) return 0; if (!host_conn) return 0;
host_conn->uri = get_uri_reference(conn->uri); host_conn->uri = get_uri_reference(conn->uri);
@ -277,7 +277,7 @@ init_connection(struct uri *uri, struct uri *proxied_uri, struct uri *referrer,
retry_connection_socket, retry_connection_socket,
done_connection_socket, done_connection_socket,
}; };
struct connection *conn = mem_calloc(1, sizeof(*conn)); struct connection *conn = (struct connection *)mem_calloc(1, sizeof(*conn));
if (!conn) return NULL; if (!conn) return NULL;
@ -568,7 +568,7 @@ init_keepalive_connection(struct connection *conn, long timeout_in_seconds,
assert(uri->host); assert(uri->host);
if_assert_failed return NULL; if_assert_failed return NULL;
keep_conn = mem_calloc(1, sizeof(*keep_conn)); keep_conn = (struct keepalive_connection *)mem_calloc(1, sizeof(*keep_conn));
if (!keep_conn) return NULL; if (!keep_conn) return NULL;
keep_conn->uri = get_uri_reference(uri); keep_conn->uri = get_uri_reference(uri);

View File

@ -106,7 +106,7 @@ add_to_dns_cache(char *name, struct sockaddr_storage *addr, int addrno)
assert(addrno > 0); assert(addrno > 0);
dnsentry = mem_calloc(1, sizeof(*dnsentry) + namelen); dnsentry = (struct dnsentry *)mem_calloc(1, sizeof(*dnsentry) + namelen);
if (!dnsentry) return; if (!dnsentry) return;
size = addrno * sizeof(*dnsentry->addr); size = addrno * sizeof(*dnsentry->addr);
@ -189,8 +189,8 @@ do_real_lookup(char *name, struct sockaddr_storage **addrs, int *addrno,
/* We cannot use mem_*() in thread ("It will chew memory on OS/2 and /* We cannot use mem_*() in thread ("It will chew memory on OS/2 and
* BeOS because there are no locks around the memory debugging code." * BeOS because there are no locks around the memory debugging code."
* -- Mikulas). So we don't if in_thread != 0. */ * -- Mikulas). So we don't if in_thread != 0. */
*addrs = in_thread ? calloc(i, sizeof(**addrs)) *addrs = (struct sockaddr_storage *)(in_thread ? calloc(i, sizeof(**addrs))
: mem_calloc(i, sizeof(**addrs)); : mem_calloc(i, sizeof(**addrs)));
if (!*addrs) return DNS_ERROR; if (!*addrs) return DNS_ERROR;
*addrno = i; *addrno = i;
@ -320,7 +320,7 @@ async_dns_reader(struct dnsquery *query)
if (read_dns_data(query->h, &query->addrno, sizeof(query->addrno)) == DNS_ERROR) if (read_dns_data(query->h, &query->addrno, sizeof(query->addrno)) == DNS_ERROR)
goto done; goto done;
query->addr = mem_calloc(query->addrno, sizeof(*query->addr)); query->addr = (struct sockaddr_storage *)mem_calloc(query->addrno, sizeof(*query->addr));
if (!query->addr) goto done; if (!query->addr) goto done;
for (i = 0; i < query->addrno; i++) { for (i = 0; i < query->addrno; i++) {
@ -473,7 +473,7 @@ init_dns_lookup(char *name, void **queryref,
struct dnsquery *query; struct dnsquery *query;
int namelen = strlen(name); int namelen = strlen(name);
query = mem_calloc(1, sizeof(*query) + namelen); query = (struct dnsquery *)mem_calloc(1, sizeof(*query) + namelen);
if (!query) { if (!query) {
done(data, NULL, 0); done(data, NULL, 0);
return DNS_ERROR; return DNS_ERROR;

View File

@ -28,7 +28,7 @@ has_progress(struct progress *progress)
struct progress * struct progress *
init_progress(off_t start) init_progress(off_t start)
{ {
struct progress *progress = mem_calloc(1, sizeof(*progress)); struct progress *progress = (struct progress *)mem_calloc(1, sizeof(*progress));
if (progress) { if (progress) {
progress->start = start; progress->start = start;

View File

@ -107,7 +107,7 @@ static struct connect_info *
init_connection_info(struct uri *uri, struct socket *socket, init_connection_info(struct uri *uri, struct socket *socket,
socket_connect_T connect_done) socket_connect_T connect_done)
{ {
struct connect_info *connect_info = mem_calloc(1, sizeof(*connect_info)); struct connect_info *connect_info = (struct connect_info *)mem_calloc(1, sizeof(*connect_info));
if (!connect_info) return NULL; if (!connect_info) return NULL;
@ -140,7 +140,7 @@ init_socket(void *conn, struct socket_operations *ops)
{ {
struct socket *socket; struct socket *socket;
socket = mem_calloc(1, sizeof(*socket)); socket = (struct socket *)mem_calloc(1, sizeof(*socket));
if (!socket) return NULL; if (!socket) return NULL;
socket->fd = -1; socket->fd = -1;
@ -1021,7 +1021,7 @@ alloc_read_buffer(struct socket *socket)
{ {
struct read_buffer *rb; struct read_buffer *rb;
rb = mem_calloc(1, RD_SIZE(rb, 0)); rb = (struct read_buffer *)mem_calloc(1, RD_SIZE(rb, 0));
if (!rb) { if (!rb) {
socket->ops->done(socket, connection_state(S_OUT_OF_MEM)); socket->ops->done(socket, connection_state(S_OUT_OF_MEM));
return NULL; return NULL;

View File

@ -177,7 +177,7 @@ get_state_message(struct connection_state state, struct terminal *term)
if (!strlcmp(s->msg, -1, e, len)) if (!strlcmp(s->msg, -1, e, len))
return s->msg; return s->msg;
s = mem_calloc(1, sizeof(*s) + len); s = (struct strerror_val *)mem_calloc(1, sizeof(*s) + len);
if (!s) return unknown_error; if (!s) return unknown_error;
memcpy(s->msg, e, len + 1); memcpy(s->msg, e, len + 1);

View File

@ -100,7 +100,7 @@ init_auth_entry(struct uri *uri, char *realm)
DBG("init_auth_entry: auth_url=%s realm=%s uri=%p", auth_url, realm, uri); DBG("init_auth_entry: auth_url=%s realm=%s uri=%p", auth_url, realm, uri);
#endif #endif
entry = mem_calloc(1, sizeof(*entry)); entry = (struct auth_entry *)mem_calloc(1, sizeof(*entry));
if (!entry) return NULL; if (!entry) return NULL;
entry->uri = get_uri_reference(uri); entry->uri = get_uri_reference(uri);

View File

@ -411,7 +411,7 @@ add_bittorrent_file(struct bittorrent_meta *meta, char *path,
pathlen = strlen(path); pathlen = strlen(path);
file = mem_calloc(1, sizeof(*file) + pathlen); file = (struct bittorrent_file *)mem_calloc(1, sizeof(*file) + pathlen);
if (!file) { if (!file) {
mem_free(path); mem_free(path);
return BITTORRENT_STATE_OUT_OF_MEM; return BITTORRENT_STATE_OUT_OF_MEM;

View File

@ -287,7 +287,7 @@ add_bittorrent_selection(struct uri *uri, int *selection, size_t size)
duplicate = get_bittorrent_selection(uri, size); duplicate = get_bittorrent_selection(uri, size);
mem_free_if(duplicate); mem_free_if(duplicate);
info = mem_calloc(1, sizeof(*info)); info = (struct bittorrent_selection_info *)mem_calloc(1, sizeof(*info));
if (!info) return; if (!info) return;
info->uri = get_uri_reference(uri); info->uri = get_uri_reference(uri);
@ -308,7 +308,7 @@ add_bittorrent_message(struct uri *uri, struct connection_state state,
struct bittorrent_message *message; struct bittorrent_message *message;
int length = string ? string->length : 0; int length = string ? string->length : 0;
message = mem_calloc(1, sizeof(*message) + length); message = (struct bittorrent_message *)mem_calloc(1, sizeof(*message) + length);
if (!message) return; if (!message) return;
message->uri = get_uri_reference(uri); message->uri = get_uri_reference(uri);

View File

@ -243,7 +243,7 @@ add_peer_to_bittorrent_pool(struct bittorrent_connection *bittorrent,
/* Really add the peer. */ /* Really add the peer. */
peer = mem_calloc(1, sizeof(*peer) + iplen); peer = (struct bittorrent_peer *)mem_calloc(1, sizeof(*peer) + iplen);
if (!peer) return BITTORRENT_STATE_OUT_OF_MEM; if (!peer) return BITTORRENT_STATE_OUT_OF_MEM;
peer->port = port; peer->port = port;
@ -402,7 +402,7 @@ init_bittorrent_fetch(struct bittorrent_fetcher **fetcher_ref,
{ {
struct bittorrent_fetcher *fetcher; struct bittorrent_fetcher *fetcher;
fetcher = mem_calloc(1, sizeof(*fetcher)); fetcher = (struct bittorrent_fetcher *)mem_calloc(1, sizeof(*fetcher));
if (!fetcher) { if (!fetcher) {
callback(data, connection_state(S_OUT_OF_MEM), NULL); callback(data, connection_state(S_OUT_OF_MEM), NULL);
return NULL; return NULL;
@ -495,7 +495,7 @@ add_bittorrent_blacklist_flags(bittorrent_id_T peer_id,
return; return;
} }
item = mem_calloc(1, sizeof(*item)); item = (struct bittorrent_blacklist_item *)mem_calloc(1, sizeof(*item));
if (!item) return; if (!item) return;
item->flags = flags; item->flags = flags;

View File

@ -284,7 +284,7 @@ init_bittorrent_connection(struct connection *conn)
assert(conn->done == NULL); assert(conn->done == NULL);
if_assert_failed return NULL; if_assert_failed return NULL;
bittorrent = mem_calloc(1, sizeof(*bittorrent)); bittorrent = (struct bittorrent_connection *)mem_calloc(1, sizeof(*bittorrent));
if (!bittorrent) return NULL; if (!bittorrent) return NULL;
init_list(bittorrent->peers); init_list(bittorrent->peers);

View File

@ -54,7 +54,7 @@ init_bittorrent_download_info(struct bittorrent_meta *meta)
struct bittorrent_file *file; struct bittorrent_file *file;
size_t max_label = 0; size_t max_label = 0;
info = mem_calloc(1, sizeof(*info)); info = (struct bittorrent_download_info *)mem_calloc(1, sizeof(*info));
if (!info) return NULL; if (!info) return NULL;
init_list(info->labels); init_list(info->labels);
@ -88,7 +88,7 @@ init_bittorrent_download_info(struct bittorrent_meta *meta)
done_string(&string); done_string(&string);
} }
info->selection = mem_calloc(info->size, sizeof(*info->selection)); info->selection = (int *)mem_calloc(info->size, sizeof(*info->selection));
if (!info->selection || info->size != list_size(&meta->files)) { if (!info->selection || info->size != list_size(&meta->files)) {
done_bittorrent_download_info(info); done_bittorrent_download_info(info);
return NULL; return NULL;

View File

@ -210,7 +210,7 @@ init_bittorrent_peer_connection(int socket)
{ {
struct bittorrent_peer_connection *peer; struct bittorrent_peer_connection *peer;
peer = mem_calloc(1, sizeof(*peer)); peer = (struct bittorrent_peer_connection *)mem_calloc(1, sizeof(*peer));
if (!peer) return NULL; if (!peer) return NULL;
peer->socket = init_socket(peer, &bittorrent_socket_operations); peer->socket = init_socket(peer, &bittorrent_socket_operations);

View File

@ -363,7 +363,7 @@ add_piece_to_bittorrent_free_list(struct bittorrent_piece_cache *cache,
/* First initialize and add all pieces to the local request list. */ /* First initialize and add all pieces to the local request list. */
do { do {
request = mem_calloc(1, sizeof(*request)); request = (struct bittorrent_peer_request *)mem_calloc(1, sizeof(*request));
if (!request) break; if (!request) break;
request->piece = piece; request->piece = piece;
@ -1263,7 +1263,7 @@ init_bittorrent_piece_cache(struct bittorrent_connection *bittorrent,
size_t cache_entry_size = sizeof(*cache->entries) * pieces; size_t cache_entry_size = sizeof(*cache->entries) * pieces;
uint32_t piece; uint32_t piece;
cache = mem_calloc(1, sizeof(*cache) + cache_entry_size); cache = (struct bittorrent_piece_cache *)mem_calloc(1, sizeof(*cache) + cache_entry_size);
if (!cache) return BITTORRENT_STATE_OUT_OF_MEM; if (!cache) return BITTORRENT_STATE_OUT_OF_MEM;
cache->bitfield = init_bitfield(pieces); cache->bitfield = init_bitfield(pieces);

View File

@ -703,7 +703,7 @@ add_file_cmd_to_str(struct connection *conn)
* simplified a little by allocating this initial structure on * simplified a little by allocating this initial structure on
* the stack, but it's several kilobytes long so that might be * the stack, but it's several kilobytes long so that might be
* risky. */ * risky. */
ftp = mem_calloc(1, sizeof(*ftp)); ftp = (struct ftp_connection_info *)mem_calloc(1, sizeof(*ftp));
if (!ftp) { if (!ftp) {
abort_connection(conn, connection_state(S_OUT_OF_MEM)); abort_connection(conn, connection_state(S_OUT_OF_MEM));
goto ret; goto ret;

View File

@ -170,7 +170,7 @@ gemini_error_document(struct connection *conn, int code)
assert(conn && conn->uri); assert(conn && conn->uri);
info = mem_calloc(1, sizeof(*info)); info = (struct gemini_error_info *)mem_calloc(1, sizeof(*info));
if (!info) return; if (!info) return;
info->code = code; info->code = code;

View File

@ -94,7 +94,7 @@ init_gemini_connection_info(struct connection *conn)
{ {
struct gemini_connection_info *gemini; struct gemini_connection_info *gemini;
gemini = mem_calloc(1, sizeof(*gemini)); gemini = (struct gemini_connection_info *)mem_calloc(1, sizeof(*gemini));
if (!gemini) { if (!gemini) {
gemini_end_request(conn, connection_state(S_OUT_OF_MEM), 0); gemini_end_request(conn, connection_state(S_OUT_OF_MEM), 0);
return NULL; return NULL;

View File

@ -329,7 +329,7 @@ init_gopher_connection_info(struct connection *conn)
} }
size = sizeof(*gopher) + command.length; size = sizeof(*gopher) + command.length;
gopher = mem_calloc(1, size); gopher = (struct gopher_connection_info *)mem_calloc(1, size);
if (!gopher) { if (!gopher) {
done_string(&command); done_string(&command);
return connection_state(S_OUT_OF_MEM); return connection_state(S_OUT_OF_MEM);

View File

@ -201,7 +201,7 @@ http_error_document(struct connection *conn, int code)
assert(conn && conn->uri); assert(conn && conn->uri);
info = mem_calloc(1, sizeof(*info)); info = (struct http_error_info *)mem_calloc(1, sizeof(*info));
if (!info) return; if (!info) return;
info->code = code; info->code = code;

View File

@ -553,7 +553,7 @@ init_http_connection_info(struct connection *conn, int major, int minor, int clo
{ {
struct http_connection_info *http; struct http_connection_info *http;
http = mem_calloc(1, sizeof(*http)); http = (struct http_connection_info *)mem_calloc(1, sizeof(*http));
if (!http) { if (!http) {
http_end_request(conn, connection_state(S_OUT_OF_MEM), 0); http_end_request(conn, connection_state(S_OUT_OF_MEM), 0);
return NULL; return NULL;

View File

@ -58,7 +58,7 @@ http_negotiate_get(struct uri *uri, int *isnew, int alloc)
if (!alloc) if (!alloc)
return NULL; return NULL;
neg = mem_calloc(1, sizeof(*neg)); neg = (struct negotiate *)mem_calloc(1, sizeof(*neg));
if (!neg) if (!neg)
return NULL; return NULL;

View File

@ -115,7 +115,7 @@ init_nntp_connection_info(struct connection *conn)
return NULL; return NULL;
} }
nntp = mem_calloc(1, sizeof(*nntp)); nntp = (struct nntp_connection_info *)mem_calloc(1, sizeof(*nntp));
if (!nntp) { if (!nntp) {
abort_connection(conn, connection_state(S_OUT_OF_MEM)); abort_connection(conn, connection_state(S_OUT_OF_MEM));
return NULL; return NULL;
@ -213,7 +213,7 @@ nntp_quit(struct connection *conn)
return; return;
} }
info = mem_calloc(1, sizeof(*info)); info = (struct nntp_connection_info *)mem_calloc(1, sizeof(*info));
if (!info) { if (!info) {
abort_connection(conn, connection_state(S_OUT_OF_MEM)); abort_connection(conn, connection_state(S_OUT_OF_MEM));
return; return;

View File

@ -1578,7 +1578,7 @@ get_uri_cache_entry(char *string, int length)
/* Setup a new entry */ /* Setup a new entry */
entry = mem_calloc(1, sizeof(*entry) + length); entry = (struct uri_cache_entry *)mem_calloc(1, sizeof(*entry) + length);
if (!entry) return NULL; if (!entry) return NULL;
object_nolock(&entry->uri, "uri"); object_nolock(&entry->uri, "uri");

View File

@ -1150,7 +1150,7 @@ smjs_session_goto_url(JSContext *ctx, unsigned int argc, JS::Value *rval)
uri = get_uri(url, URI_NONE); uri = get_uri(url, URI_NONE);
if (!uri) return false; if (!uri) return false;
deo = mem_calloc(1, sizeof(*deo)); deo = (struct delayed_open *)mem_calloc(1, sizeof(*deo));
if (!deo) { if (!deo) {
done_uri(uri); done_uri(uri);
return false; return false;

View File

@ -95,7 +95,7 @@ init_file_download(struct uri *uri, struct session *ses, char *file, int fd)
{ {
struct file_download *file_download; struct file_download *file_download;
file_download = mem_calloc(1, sizeof(*file_download)); file_download = (struct file_download *)mem_calloc(1, sizeof(*file_download));
if (!file_download) return NULL; if (!file_download) return NULL;
/* Actually we could allow fragments in the URI and just change all the /* Actually we could allow fragments in the URI and just change all the
@ -396,7 +396,7 @@ exec_mailcap_command(void *data)
static void static void
exec_later(struct session *ses, char *handler, char *file) exec_later(struct session *ses, char *handler, char *file)
{ {
struct exec_mailcap *exec_mailcap = mem_calloc(1, sizeof(*exec_mailcap)); struct exec_mailcap *exec_mailcap = (struct exec_mailcap *)mem_calloc(1, sizeof(*exec_mailcap));
if (exec_mailcap) { if (exec_mailcap) {
exec_mailcap->ses = ses; exec_mailcap->ses = ses;
@ -813,7 +813,7 @@ lookup_unique_name(struct terminal *term, char *ofile,
/* overwrite == 2 (ask) and file != ofile (=> original file already /* overwrite == 2 (ask) and file != ofile (=> original file already
* exists) */ * exists) */
lun_hop = mem_calloc(1, sizeof(*lun_hop)); lun_hop = (struct lun_hop *)mem_calloc(1, sizeof(*lun_hop));
if (!lun_hop) goto error; if (!lun_hop) goto error;
lun_hop->term = term; lun_hop->term = term;
lun_hop->ofile = ofile; lun_hop->ofile = ofile;
@ -973,7 +973,7 @@ create_download_file(struct terminal *term, char *fi,
enum download_flags flags, enum download_flags flags,
cdf_callback_T *callback, void *data) cdf_callback_T *callback, void *data)
{ {
struct cdf_hop *cdf_hop = mem_calloc(1, sizeof(*cdf_hop)); struct cdf_hop *cdf_hop = (struct cdf_hop *)mem_calloc(1, sizeof(*cdf_hop));
char *wd; char *wd;
if (!cdf_hop) { if (!cdf_hop) {
@ -1154,7 +1154,7 @@ common_download(struct session *ses, char *file,
if (!ses->download_uri) return; if (!ses->download_uri) return;
cmdw_hop = mem_calloc(1, sizeof(*cmdw_hop)); cmdw_hop = (struct cmdw_hop *)mem_calloc(1, sizeof(*cmdw_hop));
if (!cmdw_hop) return; if (!cmdw_hop) return;
cmdw_hop->ses = ses; cmdw_hop->ses = ses;
cmdw_hop->download_uri = ses->download_uri; cmdw_hop->download_uri = ses->download_uri;
@ -1210,7 +1210,7 @@ transform_codw_to_cmdw(struct terminal *term, int fd,
enum download_flags flags) enum download_flags flags)
{ {
struct type_query *type_query = codw_hop->type_query; struct type_query *type_query = codw_hop->type_query;
struct cmdw_hop *cmdw_hop = mem_calloc(1, sizeof(*cmdw_hop)); struct cmdw_hop *cmdw_hop = (struct cmdw_hop *)mem_calloc(1, sizeof(*cmdw_hop));
if (!cmdw_hop) { if (!cmdw_hop) {
close(fd); close(fd);
@ -1302,7 +1302,7 @@ static void
continue_download(void *data, char *file) continue_download(void *data, char *file)
{ {
struct type_query *type_query = data; struct type_query *type_query = data;
struct codw_hop *codw_hop = mem_calloc(1, sizeof(*codw_hop)); struct codw_hop *codw_hop = (struct codw_hop *)mem_calloc(1, sizeof(*codw_hop));
if (!codw_hop) { if (!codw_hop) {
tp_cancel(type_query); tp_cancel(type_query);
@ -1358,7 +1358,7 @@ init_type_query(struct session *ses, struct download *download,
{ {
struct type_query *type_query; struct type_query *type_query;
type_query = mem_calloc(1, sizeof(*type_query)); type_query = (struct type_query *)mem_calloc(1, sizeof(*type_query));
if (!type_query) return NULL; if (!type_query) return NULL;
type_query->uri = get_uri_reference(ses->loading_uri); type_query->uri = get_uri_reference(ses->loading_uri);
@ -1619,7 +1619,7 @@ do_type_query(struct type_query *type_query, char *ct, struct mime_handler *hand
/* Add input field or text widget with info about the program handler. */ /* Add input field or text widget with info about the program handler. */
if (!get_cmd_opt_bool("anonymous")) { if (!get_cmd_opt_bool("anonymous")) {
char *field = mem_calloc(1, MAX_STR_LEN); char *field = (char *)mem_calloc(1, MAX_STR_LEN);
if (!field) { if (!field) {
mem_free(dlg); mem_free(dlg);

View File

@ -24,7 +24,7 @@ copy_location(struct location *dst, struct location *src)
init_list(dst->frames); init_list(dst->frames);
init_list(dst->iframes); init_list(dst->iframes);
foreachback (frame, src->frames) { foreachback (frame, src->frames) {
new_frame = mem_calloc(1, sizeof(*new_frame)); new_frame = (struct frame *)mem_calloc(1, sizeof(*new_frame));
if (new_frame) { if (new_frame) {
new_frame->name = stracpy(frame->name); new_frame->name = stracpy(frame->name);
if (!new_frame->name) { if (!new_frame->name) {
@ -38,7 +38,7 @@ copy_location(struct location *dst, struct location *src)
} }
foreachback (iframe, src->iframes) { foreachback (iframe, src->iframes) {
new_iframe = mem_calloc(1, sizeof(*new_iframe)); new_iframe = (struct frame *)mem_calloc(1, sizeof(*new_iframe));
if (new_iframe) { if (new_iframe) {
new_iframe->name = stracpy(iframe->name); new_iframe->name = stracpy(iframe->name);
if (!new_iframe->name) { if (!new_iframe->name) {

View File

@ -163,7 +163,7 @@ int
add_session_info(struct session *ses, struct uri *uri, struct uri *referrer, add_session_info(struct session *ses, struct uri *uri, struct uri *referrer,
enum cache_mode cache_mode, enum task_type task) enum cache_mode cache_mode, enum task_type task)
{ {
struct session_info *info = mem_calloc(1, sizeof(*info)); struct session_info *info = (struct session_info *)mem_calloc(1, sizeof(*info));
if (!info) return -1; if (!info) return -1;
@ -320,7 +320,7 @@ print_error_dialog(struct session *ses, struct connection_state state,
N_("Error"), ALIGN_CENTER, N_("Error"), ALIGN_CENTER,
msg.source); msg.source);
} else { } else {
struct delayed_open *deo = mem_calloc(1, sizeof(*deo)); struct delayed_open *deo = (struct delayed_open *)mem_calloc(1, sizeof(*deo));
if (!deo) return; if (!deo) return;
@ -405,7 +405,7 @@ request_frame(struct session *ses, char *name,
return; return;
} }
frame = mem_calloc(1, sizeof(*frame)); frame = (struct frame *)mem_calloc(1, sizeof(*frame));
if (!frame) return; if (!frame) return;
frame->name = stracpy(name); frame->name = stracpy(name);
@ -439,7 +439,7 @@ request_iframe(struct session *ses, char *name,
return; return;
} }
iframe = mem_calloc(1, sizeof(*iframe)); iframe = (struct frame *)mem_calloc(1, sizeof(*iframe));
if (!iframe) return; if (!iframe) return;
@ -851,7 +851,7 @@ request_additional_file(struct session *ses, char *name, struct uri *uri, int pr
} }
} }
ftl = mem_calloc(1, sizeof(*ftl)); ftl = (struct file_to_load *)mem_calloc(1, sizeof(*ftl));
if (!ftl) return NULL; if (!ftl) return NULL;
@ -1032,7 +1032,7 @@ struct session *
init_session(struct session *base_session, struct terminal *term, init_session(struct session *base_session, struct terminal *term,
struct uri *uri, int in_background) struct uri *uri, int in_background)
{ {
struct session *ses = mem_calloc(1, sizeof(*ses)); struct session *ses = (struct session *)mem_calloc(1, sizeof(*ses));
if (!ses) return NULL; if (!ses) return NULL;

View File

@ -319,7 +319,7 @@ ses_forward(struct session *ses, int loaded_in_frame)
x: x:
if (!loaded_in_frame) { if (!loaded_in_frame) {
loc = mem_calloc(1, sizeof(*loc)); loc = (struct location *)mem_calloc(1, sizeof(*loc));
if (!loc) return NULL; if (!loc) return NULL;
copy_struct(&loc->download, &ses->loading); copy_struct(&loc->download, &ses->loading);
} }

View File

@ -322,10 +322,10 @@ handle_trm(int std_in, int std_out, int sock_in, int sock_out, int ctl_in,
info.magic = INTERLINK_NORMAL_MAGIC; info.magic = INTERLINK_NORMAL_MAGIC;
} }
itrm = mem_calloc(1, sizeof(*itrm)); itrm = (struct itrm *)mem_calloc(1, sizeof(*itrm));
if (!itrm) return; if (!itrm) return;
itrm->in.queue.data = mem_calloc(1, ITRM_IN_QUEUE_SIZE); itrm->in.queue.data = (unsigned char *)mem_calloc(1, ITRM_IN_QUEUE_SIZE);
if (!itrm->in.queue.data) { if (!itrm->in.queue.data) {
mem_free(itrm); mem_free(itrm);
return; return;

View File

@ -1462,7 +1462,7 @@ init_screen(void)
{ {
struct terminal_screen *screen; struct terminal_screen *screen;
screen = mem_calloc(1, sizeof(*screen)); screen = (struct terminal_screen *)mem_calloc(1, sizeof(*screen));
if (!screen) return NULL; if (!screen) return NULL;
screen->lcx = -1; screen->lcx = -1;

View File

@ -30,7 +30,7 @@
struct window * struct window *
init_tab(struct terminal *term, void *data, window_handler_T handler) init_tab(struct terminal *term, void *data, window_handler_T handler)
{ {
struct window *win = mem_calloc(1, sizeof(*win)); struct window *win = (struct window *)mem_calloc(1, sizeof(*win));
struct window *pos; struct window *pos;
if (!win) return NULL; if (!win) return NULL;

View File

@ -91,7 +91,7 @@ struct terminal *
init_term(int fdin, int fdout) init_term(int fdin, int fdout)
{ {
char name[MAX_TERM_LEN + 9] = "terminal."; char name[MAX_TERM_LEN + 9] = "terminal.";
struct terminal *term = mem_calloc(1, sizeof(*term)); struct terminal *term = (struct terminal *)mem_calloc(1, sizeof(*term));
if (!term) { if (!term) {
check_if_no_terminal(); check_if_no_terminal();

View File

@ -57,7 +57,7 @@ void
add_window(struct terminal *term, window_handler_T handler, void *data) add_window(struct terminal *term, window_handler_T handler, void *data)
{ {
struct term_event ev; struct term_event ev;
struct window *win = mem_calloc(1, sizeof(*win)); struct window *win = (struct window *)mem_calloc(1, sizeof(*win));
if (!win) { if (!win) {
mem_free_if(data); mem_free_if(data);

View File

@ -46,7 +46,7 @@ init_bitfield(size_t bits)
size_t size = get_bitfield_byte_size(bits); size_t size = get_bitfield_byte_size(bits);
struct bitfield *bitfield; struct bitfield *bitfield;
bitfield = mem_calloc(1, offsetof(struct bitfield, bits) + size); bitfield = (struct bitfield *)mem_calloc(1, offsetof(struct bitfield, bits) + size);
if (bitfield) bitfield->bitsize = bits; if (bitfield) bitfield->bitsize = bits;
return bitfield; return bitfield;

View File

@ -287,7 +287,7 @@ FF_DBG_dump_stats(struct fastfind_info *info)
static struct fastfind_info * static struct fastfind_info *
init_fastfind(struct fastfind_index *index, enum fastfind_flags flags) init_fastfind(struct fastfind_index *index, enum fastfind_flags flags)
{ {
struct fastfind_info *info = mem_calloc(1, sizeof(*info)); struct fastfind_info *info = (struct fastfind_info *)mem_calloc(1, sizeof(*info));
index->handle = info; index->handle = info;
if (!info) return NULL; if (!info) return NULL;
@ -314,7 +314,7 @@ alloc_ff_data(struct fastfind_info *info)
/* On error, cleanup is done by fastfind_done(). */ /* On error, cleanup is done by fastfind_done(). */
data = mem_calloc(info->count, sizeof(*data)); data = (struct ff_data *)mem_calloc(info->count, sizeof(*data));
if (!data) return 0; if (!data) return 0;
info->data = data; info->data = data;
FF_DBG_mem(info, info->count * sizeof(*data)); FF_DBG_mem(info, info->count * sizeof(*data));
@ -351,7 +351,7 @@ alloc_leafset(struct fastfind_info *info)
if (!leafsets) return 0; if (!leafsets) return 0;
info->leafsets = leafsets; info->leafsets = leafsets;
leafset = mem_calloc(info->uniq_chars_count, sizeof(*leafset)); leafset = (struct ff_node *)mem_calloc(info->uniq_chars_count, sizeof(*leafset));
if (!leafset) return 0; if (!leafset) return 0;
FF_DBG_mem(info, sizeof(*leafsets)); FF_DBG_mem(info, sizeof(*leafsets));

View File

@ -88,7 +88,7 @@ secure_open_umask(char *file_name)
return NULL; return NULL;
} }
ssi = mem_calloc(1, sizeof(*ssi)); ssi = (struct secure_save_info *)mem_calloc(1, sizeof(*ssi));
if (!ssi) { if (!ssi) {
secsave_errno = SS_ERR_OUT_OF_MEM; secsave_errno = SS_ERR_OUT_OF_MEM;
goto end; goto end;

View File

@ -323,7 +323,7 @@ find_form_view_in_vs(struct view_state *vs, int form_num)
if (fv->form_num == form_num) if (fv->form_num == form_num)
return fv; return fv;
fv = mem_calloc(1, sizeof(*fv)); fv = (struct form_view *)mem_calloc(1, sizeof(*fv));
fv->form_num = form_num; fv->form_num = form_num;
add_to_list(vs->forms, fv); add_to_list(vs->forms, fv);
return fv; return fv;
@ -1061,7 +1061,7 @@ encode_multipart(struct session *ses, LIST_OF(struct submitted_value) *l,
goto encode_error; goto encode_error;
} }
bfs_new = mem_calloc(1, sizeof(*bfs_new)); bfs_new = (struct files_offset *)mem_calloc(1, sizeof(*bfs_new));
if (!bfs_new) { if (!bfs_new) {
mem_free(filename); mem_free(filename);
goto encode_error; goto encode_error;

View File

@ -137,7 +137,7 @@ set_mark(unsigned char mark, struct view_state *mark_vs)
if (!mark_vs) return; if (!mark_vs) return;
vs = mem_calloc(1, sizeof(*vs)); vs = (struct view_state *)mem_calloc(1, sizeof(*vs));
if (!vs) return; if (!vs) return;
copy_vs(vs, mark_vs); copy_vs(vs, mark_vs);

View File

@ -95,23 +95,23 @@ sort_srch(struct document *document)
assert(document); assert(document);
if_assert_failed return; if_assert_failed return;
document->slines1 = mem_calloc(document->height, sizeof(*document->slines1)); document->slines1 = (struct search **)mem_calloc(document->height, sizeof(*document->slines1));
if (!document->slines1) return; if (!document->slines1) return;
document->slines2 = mem_calloc(document->height, sizeof(*document->slines2)); document->slines2 = (struct search **)mem_calloc(document->height, sizeof(*document->slines2));
if (!document->slines2) { if (!document->slines2) {
mem_free(document->slines1); mem_free(document->slines1);
return; return;
} }
min = mem_calloc(document->height, sizeof(*min)); min = (int *)mem_calloc(document->height, sizeof(*min));
if (!min) { if (!min) {
mem_free(document->slines1); mem_free(document->slines1);
mem_free(document->slines2); mem_free(document->slines2);
return; return;
} }
max = mem_calloc(document->height, sizeof(*max)); max = (int *)mem_calloc(document->height, sizeof(*max));
if (!max) { if (!max) {
mem_free(document->slines1); mem_free(document->slines1);
mem_free(document->slines2); mem_free(document->slines2);
@ -1928,7 +1928,7 @@ search_dlg_do(struct terminal *term, struct memory_list *ml,
char *text = _("Search for text", term); char *text = _("Search for text", term);
struct option *search_options; struct option *search_options;
hop = mem_calloc(1, sizeof(*hop)); hop = (struct search_dlg_hop *)mem_calloc(1, sizeof(*hop));
if (!hop) return; if (!hop) return;
search_options = get_opt_rec(config_options, "document.browse.search"); search_options = get_opt_rec(config_options, "document.browse.search");

View File

@ -578,7 +578,7 @@ init_textarea_data(struct terminal *term, struct form_state *fs,
assert(fs && doc_view && link && term); assert(fs && doc_view && link && term);
td = mem_calloc(1, sizeof(*td)); td = (struct textarea_data *)mem_calloc(1, sizeof(*td));
if (!td) return NULL; if (!td) return NULL;
td->fn = save_textarea_file(fs->value); td->fn = save_textarea_file(fs->value);

View File

@ -111,7 +111,7 @@ copy_vs(struct view_state *dst, struct view_state *src)
init_list(dst->forms); init_list(dst->forms);
foreach (fv, src->forms) { foreach (fv, src->forms) {
struct form_view *newfv = mem_calloc(1, sizeof(*newfv)); struct form_view *newfv = (struct form_view *)mem_calloc(1, sizeof(*newfv));
if (!newfv) continue; if (!newfv) continue;
newfv->form_num = fv->form_num; newfv->form_num = fv->form_num;