Remove redundant casts from void* with malloc functions
* src/msdos.c (IT_menu_make_room): * src/pgtkterm.c (pgtk_define_fringe_bitmap): * src/w16select.c (set_clipboard_data): * src/w32term.c (w32_define_fringe_bitmap): * src/w32uniscribe.c (uniscribe_shape): Remove redundant cast from void* with xrealloc. * admin/coccinelle/alloc_cast.cocci: New semantic patch.
This commit is contained in:
parent
83ee584052
commit
1a2fa8f413
6 changed files with 14 additions and 15 deletions
6
admin/coccinelle/alloc_cast.cocci
Normal file
6
admin/coccinelle/alloc_cast.cocci
Normal file
|
@ -0,0 +1,6 @@
|
|||
// Remove redundant casts from memory allocation functions.
|
||||
@@
|
||||
type T;
|
||||
@@
|
||||
-(T *)
|
||||
\(xmalloc\|xzalloc\|xrealloc\|xpalloc\|xnrealloc\)(...)
|
12
src/msdos.c
12
src/msdos.c
|
@ -2811,14 +2811,10 @@ IT_menu_make_room (XMenu *menu)
|
|||
else if (menu->allocated == menu->count)
|
||||
{
|
||||
int count = menu->allocated = menu->allocated + 10;
|
||||
menu->text
|
||||
= (char **) xrealloc (menu->text, count * sizeof (char *));
|
||||
menu->submenu
|
||||
= (XMenu **) xrealloc (menu->submenu, count * sizeof (XMenu *));
|
||||
menu->panenumber
|
||||
= (int *) xrealloc (menu->panenumber, count * sizeof (int));
|
||||
menu->help_text
|
||||
= (const char **) xrealloc (menu->help_text, count * sizeof (char *));
|
||||
menu->text = xrealloc (menu->text, count * sizeof (char *));
|
||||
menu->submenu = xrealloc (menu->submenu, count * sizeof (XMenu *));
|
||||
menu->panenumber = xrealloc (menu->panenumber, count * sizeof (int));
|
||||
menu->help_text = xrealloc (menu->help_text, count * sizeof (char *));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3471,9 +3471,7 @@ pgtk_define_fringe_bitmap (int which, unsigned short *bits, int h, int wd)
|
|||
i = max_fringe_bmp;
|
||||
max_fringe_bmp = which + 20;
|
||||
fringe_bmp
|
||||
= (cairo_pattern_t **) xrealloc (fringe_bmp,
|
||||
max_fringe_bmp *
|
||||
sizeof (cairo_pattern_t *));
|
||||
= xrealloc (fringe_bmp, max_fringe_bmp * sizeof (cairo_pattern_t *));
|
||||
while (i < max_fringe_bmp)
|
||||
fringe_bmp[i++] = 0;
|
||||
}
|
||||
|
|
|
@ -275,7 +275,7 @@ set_clipboard_data (unsigned Format, void *Data, unsigned Size, int Raw)
|
|||
{
|
||||
clipboard_storage_size = truelen + 100;
|
||||
last_clipboard_text =
|
||||
(char *) xrealloc (last_clipboard_text, clipboard_storage_size);
|
||||
xrealloc (last_clipboard_text, clipboard_storage_size);
|
||||
}
|
||||
if (last_clipboard_text)
|
||||
dosmemget (xbuf_addr, truelen, last_clipboard_text);
|
||||
|
|
|
@ -949,7 +949,7 @@ w32_define_fringe_bitmap (int which, unsigned short *bits, int h, int wd)
|
|||
{
|
||||
int i = max_fringe_bmp;
|
||||
max_fringe_bmp = which + 20;
|
||||
fringe_bmp = (HBITMAP *) xrealloc (fringe_bmp, max_fringe_bmp * sizeof (HBITMAP));
|
||||
fringe_bmp = xrealloc (fringe_bmp, max_fringe_bmp * sizeof (HBITMAP));
|
||||
while (i < max_fringe_bmp)
|
||||
fringe_bmp[i++] = 0;
|
||||
}
|
||||
|
|
|
@ -330,8 +330,7 @@ uniscribe_shape (Lisp_Object lgstring, Lisp_Object direction)
|
|||
{
|
||||
/* If that wasn't enough, keep trying with one more run. */
|
||||
max_items++;
|
||||
items = (SCRIPT_ITEM *) xrealloc (items,
|
||||
sizeof (SCRIPT_ITEM) * max_items + 1);
|
||||
items = xrealloc (items, sizeof (SCRIPT_ITEM) * max_items + 1);
|
||||
}
|
||||
|
||||
if (FAILED (result))
|
||||
|
|
Loading…
Add table
Reference in a new issue