mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[mem_realloc] cast return value
This commit is contained in:
parent
20c161559c
commit
be8a030fa7
@ -82,7 +82,7 @@ new_menu_item(struct list_menu *menu, char *name, int data, int fullname)
|
||||
|
||||
if (data == -1) {
|
||||
int size = (menu->stack_size + 1) * sizeof(*menu->stack);
|
||||
struct menu_item **stack = mem_realloc(menu->stack, size);
|
||||
struct menu_item **stack = (struct menu_item **)mem_realloc(menu->stack, size);
|
||||
|
||||
if (stack) {
|
||||
menu->stack = stack;
|
||||
|
@ -428,7 +428,7 @@ extract_rows_or_cols_values(char *str, int max_value, int pixels_per_char,
|
||||
}
|
||||
|
||||
/* Save value. */
|
||||
tmp_values = mem_realloc(values, (values_count + 1) * sizeof(*tmp_values));
|
||||
tmp_values = (int *)mem_realloc(values, (values_count + 1) * sizeof(*tmp_values));
|
||||
if (!tmp_values) return 0;
|
||||
|
||||
values = tmp_values;
|
||||
|
@ -37,9 +37,9 @@ void add_iframeset_entry(struct iframeset_desc **parent,
|
||||
if_assert_failed return;
|
||||
|
||||
if (!*parent) {
|
||||
*parent = mem_calloc(1, sizeof(struct iframeset_desc));
|
||||
*parent = (struct iframeset_desc *)mem_calloc(1, sizeof(struct iframeset_desc));
|
||||
} else {
|
||||
*parent = mem_realloc(*parent, sizeof(struct iframeset_desc) + ((*parent)->n + 1) * sizeof(struct iframe_desc));
|
||||
*parent = (struct iframeset_desc *)mem_realloc(*parent, sizeof(struct iframeset_desc) + ((*parent)->n + 1) * sizeof(struct iframe_desc));
|
||||
}
|
||||
if (!*parent) return;
|
||||
|
||||
|
@ -633,7 +633,7 @@ look_for_link(char **pos, char *eof, struct menu_item **menu,
|
||||
}
|
||||
}
|
||||
|
||||
nm = mem_realloc(*menu, (nmenu + 2) * sizeof(*nm));
|
||||
nm = (struct menu_item *)mem_realloc(*menu, (nmenu + 2) * sizeof(*nm));
|
||||
if (nm) {
|
||||
*menu = nm;
|
||||
memset(&nm[nmenu], 0, 2 * sizeof(*nm));
|
||||
|
@ -446,7 +446,7 @@ new_columns(struct table *table, int span, int width, int align,
|
||||
sizeof(*new_columns), SMART_RAISE_LIMIT);
|
||||
if (!n) return;
|
||||
|
||||
new_columns = mem_realloc(table->columns, n * sizeof(*new_columns));
|
||||
new_columns = (struct table_column *)mem_realloc(table->columns, n * sizeof(*new_columns));
|
||||
if (!new_columns) return;
|
||||
|
||||
table->real_columns_count = n;
|
||||
@ -476,7 +476,7 @@ set_td_width(struct table *table, int col, int width, int force)
|
||||
if (!n && table->cols_x_count) return;
|
||||
if (!n) n = col + 1;
|
||||
|
||||
new_cols_x = mem_realloc(table->cols_x, n * sizeof(*new_cols_x));
|
||||
new_cols_x = (int *)mem_realloc(table->cols_x, n * sizeof(*new_cols_x));
|
||||
if (!new_cols_x) return;
|
||||
|
||||
for (i = table->cols_x_count; i < n; i++)
|
||||
|
@ -38,7 +38,7 @@ realloc_dom_node_list(struct dom_node_list **oldlist)
|
||||
|
||||
if (newsize <= oldsize) return list;
|
||||
|
||||
list = mem_realloc(list, DOM_NODE_LIST_SIZE(newsize));
|
||||
list = (struct dom_node_list *)mem_realloc(list, DOM_NODE_LIST_SIZE(newsize));
|
||||
if (!list) return NULL;
|
||||
|
||||
/* If this is the first reallocation clear the size */
|
||||
|
@ -57,7 +57,7 @@ add_to_dom_string(struct dom_string *string, char *str, size_t len)
|
||||
{
|
||||
char *newstring;
|
||||
|
||||
newstring = mem_realloc(string->string, string->length + len + 1);
|
||||
newstring = (char *)mem_realloc(string->string, string->length + len + 1);
|
||||
if (!newstring)
|
||||
return NULL;
|
||||
|
||||
|
@ -131,7 +131,7 @@ brotli_decode_buffer(struct stream_encoded *st, char *datac, int len, int *new_l
|
||||
do {
|
||||
char *new_buffer;
|
||||
size_t size = enc_data->total_out + ELINKS_BROTLI_BUFFER_LENGTH;
|
||||
new_buffer = mem_realloc(enc_data->buffer, size);
|
||||
new_buffer = (char *)mem_realloc(enc_data->buffer, size);
|
||||
|
||||
if (!new_buffer) {
|
||||
error = BROTLI_DECODER_RESULT_ERROR;
|
||||
|
@ -159,7 +159,7 @@ bzip2_decode_buffer(struct stream_encoded *st, char *data, int len, int *new_len
|
||||
* --jonas */
|
||||
assertm(!stream->total_out_hi32, "64 bzip2 decoding not supported");
|
||||
|
||||
new_buffer = mem_realloc(buffer, size);
|
||||
new_buffer = (char *)mem_realloc(buffer, size);
|
||||
if (!new_buffer) {
|
||||
error = BZ_MEM_ERROR;
|
||||
break;
|
||||
|
@ -185,7 +185,7 @@ deflate_decode_buffer(struct stream_encoded *st, int window_size, char *datac, i
|
||||
unsigned char *new_buffer;
|
||||
size_t size = stream->total_out + MAX_STR_LEN;
|
||||
|
||||
new_buffer = mem_realloc(buffer, size);
|
||||
new_buffer = (unsigned char *)mem_realloc(buffer, size);
|
||||
if (!new_buffer) {
|
||||
error = Z_MEM_ERROR;
|
||||
break;
|
||||
|
@ -127,7 +127,7 @@ lzma_decode_buffer(struct stream_encoded *st, unsigned char *data, int len, int
|
||||
char *new_buffer;
|
||||
size_t size = stream->total_out + MAX_STR_LEN;
|
||||
|
||||
new_buffer = mem_realloc(buffer, size);
|
||||
new_buffer = (char *)mem_realloc(buffer, size);
|
||||
if (!new_buffer) {
|
||||
error = LZMA_MEM_ERROR;
|
||||
break;
|
||||
|
@ -76,7 +76,7 @@ zstd_decode_buffer(struct stream_encoded *st, char *data, int len, int *new_len)
|
||||
char *new_buffer;
|
||||
size_t size = enc_data->output.size + ELINKS_ZSTD_BUFFER_LENGTH;
|
||||
|
||||
new_buffer = mem_realloc(enc_data->output.dst, size);
|
||||
new_buffer = (char *)mem_realloc(enc_data->output.dst, size);
|
||||
if (!new_buffer) {
|
||||
error = 1;
|
||||
break;
|
||||
@ -109,7 +109,7 @@ zstd_read(struct stream_encoded *stream, char *buf, int len)
|
||||
|
||||
if (!data->decoded) {
|
||||
size_t read_pos = 0;
|
||||
char *tmp_buf = malloc(len);
|
||||
char *tmp_buf = (char *)mem_alloc(len);
|
||||
int new_len;
|
||||
|
||||
if (!tmp_buf) {
|
||||
|
@ -823,7 +823,7 @@ get_combined(unicode_val_T *data, int length)
|
||||
last_combined++;
|
||||
indeks = last_combined - UCS_BEGIN_COMBINED;
|
||||
|
||||
combined = mem_realloc(combined, sizeof(*combined) * (indeks + 1));
|
||||
combined = (unicode_val_T **)mem_realloc(combined, sizeof(*combined) * (indeks + 1));
|
||||
if (!combined) {
|
||||
mem_free(key);
|
||||
last_combined--;
|
||||
@ -1459,7 +1459,7 @@ flush:
|
||||
callback(callback_data, buffer, bufferpos);
|
||||
bufferpos = 0;
|
||||
} else {
|
||||
new_ = mem_realloc(buffer, bufferpos + ALLOC_GR);
|
||||
new_ = (char *)mem_realloc(buffer, bufferpos + ALLOC_GR);
|
||||
if (!new_) {
|
||||
mem_free(buffer);
|
||||
return NULL;
|
||||
|
@ -219,7 +219,7 @@ register_event_hook(int id, event_hook_T callback, int priority, void *data)
|
||||
if (i == event->count) {
|
||||
struct event_handler *eh;
|
||||
|
||||
eh = mem_realloc(event->handlers,
|
||||
eh = (struct event_handler *)mem_realloc(event->handlers,
|
||||
(event->count + 1) * sizeof(*event->handlers));
|
||||
|
||||
if (!eh) return EVENT_NONE;
|
||||
@ -268,7 +268,7 @@ unregister_event_hook(int id, event_hook_T callback)
|
||||
} else {
|
||||
struct event_handler *eh;
|
||||
|
||||
eh = mem_realloc(event->handlers,
|
||||
eh = (struct event_handler *)mem_realloc(event->handlers,
|
||||
event->count * sizeof(*event->handlers));
|
||||
if (eh) event->handlers = eh;
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ set_handlers(int fd, select_handler_T read_func, select_handler_T write_func,
|
||||
return;
|
||||
}
|
||||
if (fd >= n_threads) {
|
||||
struct thread *tmp_threads = mem_realloc(threads, (fd + 1) * sizeof(struct thread));
|
||||
struct thread *tmp_threads = (struct thread *)mem_realloc(threads, (fd + 1) * sizeof(struct thread));
|
||||
|
||||
if (!tmp_threads) {
|
||||
elinks_internal("out of memory");
|
||||
|
@ -960,7 +960,7 @@ read_select(struct socket *socket)
|
||||
if (!rb->freespace) {
|
||||
int size = RD_SIZE(rb, rb->length);
|
||||
|
||||
rb = mem_realloc(rb, size);
|
||||
rb = (struct read_buffer *)mem_realloc(rb, size);
|
||||
if (!rb) {
|
||||
socket->ops->done(socket, connection_state(S_OUT_OF_MEM));
|
||||
return;
|
||||
|
@ -191,7 +191,7 @@ sort_and_display_entries(FSP_DIR *dir, const char dircolor[])
|
||||
if (!fresult) break;
|
||||
if (!strcmp(fentry.name, "."))
|
||||
continue;
|
||||
new_table = mem_realloc(table, (size + 1) * sizeof(*table));
|
||||
new_table = (FSP_RDENTRY *)mem_realloc(table, (size + 1) * sizeof(*table));
|
||||
if (!new_table)
|
||||
continue;
|
||||
table = new_table;
|
||||
|
@ -808,7 +808,7 @@ add_file_cmd_to_str(struct connection *conn)
|
||||
ftp->opc = ftp->pending_commands;
|
||||
|
||||
/* 1 byte is already reserved for cmd_buffer in struct ftp_connection_info. */
|
||||
ftp = mem_realloc(ftp, sizeof(*ftp) + command.length);
|
||||
ftp = (struct ftp_connection_info *)mem_realloc(ftp, sizeof(*ftp) + command.length);
|
||||
if (!ftp) {
|
||||
abort_connection(conn, connection_state(S_OUT_OF_MEM));
|
||||
goto ret;
|
||||
|
@ -125,7 +125,7 @@ open_http_post(struct http_post *http_post, const char *post_data,
|
||||
/* This use of mem_realloc() in a loop consumes O(n^2)
|
||||
* time but how many files are you really going to
|
||||
* upload in one request? */
|
||||
new_files = mem_realloc(http_post->files,
|
||||
new_files = (struct http_post_file *)mem_realloc(http_post->files,
|
||||
(http_post->file_count + 1)
|
||||
* sizeof(*new_files));
|
||||
if (new_files == NULL) {
|
||||
|
@ -93,7 +93,7 @@ get_smb_directory_entries(int dir, struct string *prefix)
|
||||
if (!strcmp(entry->name, "."))
|
||||
continue;
|
||||
|
||||
new_entries = mem_realloc(entries, (size + 2) * sizeof(*new_entries));
|
||||
new_entries = (struct directory_entry *)mem_realloc(entries, (size + 2) * sizeof(*new_entries));
|
||||
if (!new_entries) continue;
|
||||
entries = new_entries;
|
||||
|
||||
|
@ -225,7 +225,7 @@ l_pipe_read(LS)
|
||||
size_t l = fread(buf, 1, sizeof(buf), fp);
|
||||
|
||||
if (l > 0) {
|
||||
char *news = mem_realloc(s, len + l);
|
||||
char *news = (char *)mem_realloc(s, len + l);
|
||||
|
||||
if (!news) goto lua_error;
|
||||
s = news;
|
||||
|
@ -469,7 +469,7 @@ in_term(struct terminal *term)
|
||||
int queuesize = ((qlen + ALLOC_GR) & ~(ALLOC_GR - 1));
|
||||
int newsize = sizeof(*interlink) + queuesize;
|
||||
|
||||
interlink = mem_realloc(interlink, newsize);
|
||||
interlink = (struct terminal_interlink *)mem_realloc(interlink, newsize);
|
||||
if (!interlink) {
|
||||
destroy_terminal(term);
|
||||
return;
|
||||
|
@ -124,7 +124,7 @@ itrm_queue_event(struct itrm *itrm, char *data, int len)
|
||||
|
||||
if (w < len) {
|
||||
int left = len - w;
|
||||
unsigned char *c = mem_realloc(itrm->out.queue.data,
|
||||
unsigned char *c = (unsigned char *)mem_realloc(itrm->out.queue.data,
|
||||
itrm->out.queue.len + left);
|
||||
|
||||
if (!c) {
|
||||
|
@ -1493,7 +1493,7 @@ resize_screen(struct terminal *term, int width, int height)
|
||||
|
||||
bsize = size * sizeof(*image);
|
||||
|
||||
image = mem_realloc(screen->image, bsize * 2);
|
||||
image = (struct screen_char *)mem_realloc(screen->image, bsize * 2);
|
||||
if (!image) return;
|
||||
|
||||
screen->image = image;
|
||||
|
@ -346,7 +346,7 @@ alloc_leafset(struct fastfind_info *info)
|
||||
|
||||
/* info->leafsets[0] is never used since l=0 marks no leaf
|
||||
* in struct ff_node. That's the reason of that + 2. */
|
||||
leafsets = mem_realloc(info->leafsets,
|
||||
leafsets = (struct ff_node **)mem_realloc(info->leafsets,
|
||||
sizeof(*leafsets) * (info->leafsets_count + 2));
|
||||
if (!leafsets) return 0;
|
||||
info->leafsets = leafsets;
|
||||
|
@ -214,7 +214,7 @@ file_read_line(char *line, size_t *size, FILE *file, int *lineno)
|
||||
offset = *size - 1;
|
||||
*size += MAX_STR_LEN;
|
||||
|
||||
newline = mem_realloc(line, *size);
|
||||
newline = (char *)mem_realloc(line, *size);
|
||||
if (!newline)
|
||||
break;
|
||||
line = newline;
|
||||
@ -332,7 +332,7 @@ get_directory_entries(char *dirname, int get_hidden)
|
||||
if (!file_visible(entry->d_name, get_hidden, is_root_directory))
|
||||
continue;
|
||||
|
||||
new_entries = mem_realloc(entries, (size + 2) * sizeof(*new_entries));
|
||||
new_entries = (struct directory_entry *)mem_realloc(entries, (size + 2) * sizeof(*new_entries));
|
||||
if (!new_entries) continue;
|
||||
entries = new_entries;
|
||||
|
||||
|
@ -114,7 +114,7 @@ add_to_ml(struct memory_list **ml, ...)
|
||||
/* Enlarge existing ml. */
|
||||
struct memory_list *nml;
|
||||
|
||||
nml = mem_realloc(*ml, ML_SIZE(n + (*ml)->n));
|
||||
nml = (struct memory_list *)mem_realloc(*ml, ML_SIZE(n + (*ml)->n));
|
||||
if (!nml) return;
|
||||
|
||||
*ml = nml;
|
||||
@ -155,7 +155,7 @@ add_one_to_ml(struct memory_list **ml, void *p)
|
||||
/* Enlarge existing ml. */
|
||||
struct memory_list *nml;
|
||||
|
||||
nml = mem_realloc(*ml, ML_SIZE(1 + (*ml)->n));
|
||||
nml = (struct memory_list *)mem_realloc(*ml, ML_SIZE(1 + (*ml)->n));
|
||||
if (!nml) return;
|
||||
|
||||
*ml = nml;
|
||||
|
@ -110,7 +110,7 @@ add_to_strn(char **dst, const char *src)
|
||||
|
||||
dstlen = strlen(*dst);
|
||||
srclen = strlen(src) + 1; /* Include the NUL char! */
|
||||
newdst = mem_realloc(*dst, dstlen + srclen);
|
||||
newdst = (char *)mem_realloc(*dst, dstlen + srclen);
|
||||
if (!newdst) return;
|
||||
|
||||
memcpy(newdst + dstlen, src, srclen);
|
||||
@ -122,7 +122,7 @@ insert_in_string(char **dst, int pos,
|
||||
const char *seq, int seqlen)
|
||||
{
|
||||
int dstlen = strlen(*dst);
|
||||
char *string = mem_realloc(*dst, dstlen + seqlen + 1);
|
||||
char *string = (char *)mem_realloc(*dst, dstlen + seqlen + 1);
|
||||
|
||||
if (!string) return NULL;
|
||||
|
||||
@ -157,7 +157,7 @@ straconcat(const char *str, ...)
|
||||
|
||||
if (!l) continue;
|
||||
|
||||
ns = mem_realloc(s, len + 1 + l);
|
||||
ns = (char *)mem_realloc(s, len + 1 + l);
|
||||
if (!ns) {
|
||||
mem_free(s);
|
||||
va_end(ap);
|
||||
|
@ -1645,7 +1645,7 @@ field_op(struct session *ses, struct document_view *doc_view,
|
||||
|
||||
length = strlen(text);
|
||||
if (length <= fc->maxlength) {
|
||||
char *v = mem_realloc(fs->value, length + 1);
|
||||
char *v = (char *)mem_realloc(fs->value, length + 1);
|
||||
|
||||
if (v) {
|
||||
fs->value = v;
|
||||
|
Loading…
Reference in New Issue
Block a user