diff --git a/src/bfu/menu.c b/src/bfu/menu.c index 1b25f1cf..a7e1fb06 100644 --- a/src/bfu/menu.c +++ b/src/bfu/menu.c @@ -1146,7 +1146,7 @@ mainmenu_handler(struct window *win, struct term_event *ev) /* For dynamic menus the last (cleared) item is used to mark the end. */ #define realloc_menu_items(mi_, size) \ - mem_align_alloc(mi_, size, (size) + 2, struct menu_item, 0xF) + mem_align_alloc(mi_, size, (size) + 2, 0xF) struct menu_item * new_menu(enum menu_item_flags flags) diff --git a/src/bfu/text.c b/src/bfu/text.c index 63f00f4d..e4e9d438 100644 --- a/src/bfu/text.c +++ b/src/bfu/text.c @@ -83,7 +83,7 @@ split_line(unsigned char *text, int max_width) #undef is_unsplitable #define LINES_GRANULARITY 0x7 -#define realloc_lines(x, o, n) mem_align_alloc(x, o, n, unsigned char *, LINES_GRANULARITY) +#define realloc_lines(x, o, n) mem_align_alloc(x, o, n, LINES_GRANULARITY) /* Find the start of each line with the current max width */ static unsigned char ** diff --git a/src/document/docdata.h b/src/document/docdata.h index f898db3c..1606966f 100644 --- a/src/document/docdata.h +++ b/src/document/docdata.h @@ -8,12 +8,12 @@ #define LINE_GRANULARITY 0x0F #define LINK_GRANULARITY 0x7F -#define ALIGN_LINES(x, o, n) mem_align_alloc(x, o, n, struct line, LINES_GRANULARITY) -#define ALIGN_LINE(x, o, n) mem_align_alloc(x, o, n, struct screen_char, LINE_GRANULARITY) -#define ALIGN_LINK(x, o, n) mem_align_alloc(x, o, n, struct link, LINK_GRANULARITY) +#define ALIGN_LINES(x, o, n) mem_align_alloc(x, o, n, LINES_GRANULARITY) +#define ALIGN_LINE(x, o, n) mem_align_alloc(x, o, n, LINE_GRANULARITY) +#define ALIGN_LINK(x, o, n) mem_align_alloc(x, o, n, LINK_GRANULARITY) #define realloc_points(link, size) \ - mem_align_alloc(&(link)->points, (link)->npoints, size, struct point, 0) + mem_align_alloc(&(link)->points, (link)->npoints, size, 0) struct line *realloc_lines(struct document *document, int y); diff --git a/src/document/html/parser/forms.c b/src/document/html/parser/forms.c index 6e63f96d..dc2ddbfa 100644 --- a/src/document/html/parser/forms.c +++ b/src/document/html/parser/forms.c @@ -424,7 +424,7 @@ abort: preselect = order; value = get_attr_val(t_attr, "value", html_context->options); - if (!mem_align_alloc(&values, order, order + 1, unsigned char *, 0xFF)) + if (!mem_align_alloc(&values, order, order + 1, 0xFF)) goto abort; values[order++] = value; diff --git a/src/document/html/parser/parse.c b/src/document/html/parser/parse.c index 0fafd047..92243327 100644 --- a/src/document/html/parser/parse.c +++ b/src/document/html/parser/parse.c @@ -126,7 +126,7 @@ end: } -#define realloc_chrs(x, l) mem_align_alloc(x, l, (l) + 1, unsigned char, 0xFF) +#define realloc_chrs(x, l) mem_align_alloc(x, l, (l) + 1, 0xFF) #define add_chr(s, l, c) \ do { \ diff --git a/src/document/html/parser/table.c b/src/document/html/parser/table.c index 1275cfb2..00e1a460 100644 --- a/src/document/html/parser/table.c +++ b/src/document/html/parser/table.c @@ -31,7 +31,7 @@ #define INIT_REAL_ROWS 2 #define realloc_bad_html(bad_html, size) \ - mem_align_alloc(bad_html, size, (size) + 1, struct html_start_end, 0xFF) + mem_align_alloc(bad_html, size, (size) + 1, 0xFF) static void add_table_bad_html_start(struct table *table, unsigned char *start) diff --git a/src/document/html/renderer.c b/src/document/html/renderer.c index 7ec24e72..63915faf 100644 --- a/src/document/html/renderer.c +++ b/src/document/html/renderer.c @@ -134,7 +134,7 @@ void put_chars(struct html_context *, unsigned char *, int); #define SPACES_GRANULARITY 0x7F -#define ALIGN_SPACES(x, o, n) mem_align_alloc(x, o, n, unsigned char, SPACES_GRANULARITY) +#define ALIGN_SPACES(x, o, n) mem_align_alloc(x, o, n, SPACES_GRANULARITY) static inline void set_screen_char_color(struct screen_char *schar, diff --git a/src/dom/stack.c b/src/dom/stack.c index 5546757d..4b750454 100644 --- a/src/dom/stack.c +++ b/src/dom/stack.c @@ -24,7 +24,6 @@ static inline struct dom_stack_state * realloc_dom_stack_states(struct dom_stack_state **states, size_t size) { return mem_align_alloc(states, size, size + 1, - struct dom_stack_state, DOM_STACK_STATE_GRANULARITY); } @@ -32,7 +31,6 @@ static inline struct dom_stack_state * realloc_dom_stack_context(struct dom_stack_context ***contexts, size_t size) { return mem_align_alloc(contexts, size, size + 1, - struct dom_stack_context *, DOM_STACK_STATE_GRANULARITY); } diff --git a/src/main/event.c b/src/main/event.c index 5b8bab76..27f63bfa 100644 --- a/src/main/event.c +++ b/src/main/event.c @@ -65,7 +65,7 @@ static struct hash *event_hash = NULL; #define EVENT_GRANULARITY 0x07 #define realloc_events(ptr, size) \ - mem_align_alloc(ptr, (size), (size) + 1, struct event, EVENT_GRANULARITY) + mem_align_alloc(ptr, (size), (size) + 1, EVENT_GRANULARITY) static inline int invalid_event_id(register int id) diff --git a/src/protocol/uri.c b/src/protocol/uri.c index 45dae8c2..c42723e2 100644 --- a/src/protocol/uri.c +++ b/src/protocol/uri.c @@ -1406,7 +1406,7 @@ decode_uri_string_for_display(struct string *string) #define realloc_uri_list(list) \ mem_align_alloc(&(list)->uris, (list)->size, (list)->size + 1, \ - struct uri *, URI_LIST_GRANULARITY) + URI_LIST_GRANULARITY) struct uri * add_to_uri_list(struct uri_list *list, struct uri *uri) diff --git a/src/util/memory.h b/src/util/memory.h index 2864408b..87cf2cc4 100644 --- a/src/util/memory.h +++ b/src/util/memory.h @@ -152,11 +152,11 @@ mem_align_alloc__( } #ifdef DEBUG_MEMLEAK -#define mem_align_alloc(ptr, old, new, obj, mask) \ - mem_align_alloc__(__FILE__, __LINE__, (void **) ptr, old, new, sizeof(obj), mask) +#define mem_align_alloc(ptr, old, new, mask) \ + mem_align_alloc__(__FILE__, __LINE__, (void **) ptr, old, new, sizeof(**ptr), mask) #else -#define mem_align_alloc(ptr, old, new, obj, mask) \ - mem_align_alloc__((void **) ptr, old, new, sizeof(obj), mask) +#define mem_align_alloc(ptr, old, new, mask) \ + mem_align_alloc__((void **) ptr, old, new, sizeof(**ptr), mask) #endif diff --git a/src/util/string.h b/src/util/string.h index 7390061c..1b069efd 100644 --- a/src/util/string.h +++ b/src/util/string.h @@ -184,7 +184,7 @@ squeezastring(struct string *string) #define realloc_string(str, size) \ mem_align_alloc(&(str)->source, (str)->length, (size) + 1, \ - unsigned char, STRING_GRANULARITY) + STRING_GRANULARITY) #ifdef DEBUG_MEMLEAK diff --git a/src/viewer/text/form.c b/src/viewer/text/form.c index 1ffd2d08..90b809f1 100644 --- a/src/viewer/text/form.c +++ b/src/viewer/text/form.c @@ -206,8 +206,7 @@ find_form_state(struct document_view *doc_view, struct form_control *fc) if (n >= vs->form_info_len) { int nn = n + 1; - fs = mem_align_alloc(&vs->form_info, vs->form_info_len, nn, - struct form_state, 0); + fs = mem_align_alloc(&vs->form_info, vs->form_info_len, nn, 0); if (!fs) return NULL; vs->form_info = fs; vs->form_info_len = nn; @@ -629,7 +628,7 @@ encode_controls(struct list_head *l, struct string *data, #define BOUNDARY_LENGTH 32 #define realloc_bound_ptrs(bptrs, bptrs_size) \ - mem_align_alloc(bptrs, bptrs_size, bptrs_size + 1, int, 0xFF) + mem_align_alloc(bptrs, bptrs_size, bptrs_size + 1, 0xFF) struct boundary_info { int count; diff --git a/src/viewer/text/search.c b/src/viewer/text/search.c index 53716882..022e9369 100644 --- a/src/viewer/text/search.c +++ b/src/viewer/text/search.c @@ -539,7 +539,7 @@ is_in_range(struct document *document, int y, int height, } #define realloc_points(pts, size) \ - mem_align_alloc(pts, size, (size) + 1, struct point, 0xFF) + mem_align_alloc(pts, size, (size) + 1, 0xFF) static void get_searched_plain(struct document_view *doc_view, struct point **pt, int *pl, diff --git a/src/viewer/text/textarea.c b/src/viewer/text/textarea.c index f8e66ded..6d5b512e 100644 --- a/src/viewer/text/textarea.c +++ b/src/viewer/text/textarea.c @@ -45,7 +45,7 @@ struct line_info { /* We add two extra entries to the table so the ending info can be added * without reallocating. */ #define realloc_line_info(info, size) \ - mem_align_alloc(info, size, (size) + 3, struct line_info, 0xFF) + mem_align_alloc(info, size, (size) + 3, 0xFF) /* Allocates a line_info table describing the layout of the textarea buffer. *