1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-25 01:05:37 +00:00

[mem_alloc] cast return value

This commit is contained in:
Witold Filipczyk 2022-01-16 19:09:27 +01:00
parent 75a0b14748
commit 20c161559c
77 changed files with 116 additions and 116 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -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)

View File

@ -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_;

View File

@ -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);

View File

@ -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. */

View File

@ -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;

View File

@ -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);

View File

@ -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,

View File

@ -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));

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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");

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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");

View File

@ -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

View File

@ -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);

View File

@ -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));

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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));

View File

@ -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 ... */

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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. */

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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) {

View File

@ -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;