summaryrefslogtreecommitdiff
path: root/src/dispnew.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-07-05 11:35:48 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-07-05 11:35:48 -0700
commit38182d901d030c7d65f4aa7a49b583afb30eb9b7 (patch)
treea69e1a571495d6ca1c034359d7c995639774ab9b /src/dispnew.c
parent6dd5a677dbf794eedaa8325c46d57ac041373361 (diff)
downloademacs-38182d901d030c7d65f4aa7a49b583afb30eb9b7.tar.gz
More xmalloc and related cleanup.
* alloc.c, bidi.c, buffer.c, buffer.h, bytecode.c, callint.c: * callproc.c, charset.c, coding.c, composite.c, data.c, dispnew.c: * doc.c, editfns.c, emacs.c, eval.c, fileio.c, filelock.c, fns.c: * font.c, fontset.c, frame.c, fringe.c, ftfont.c, ftxfont.c, gmalloc.c: * gtkutil.c, image.c, keyboard.c, keymap.c, lread.c, macros.c, menu.c: * nsfns.m, nsfont.m, nsmenu.m, nsterm.m, print.c, process.c, ralloc.c: * regex.c, region-cache.c, scroll.c, search.c, sound.c, syntax.c: * sysdep.c, term.c, termcap.c, unexmacosx.c, window.c, xdisp.c: * xfaces.c, xfns.c, xftfont.c, xgselect.c, xmenu.c, xrdb.c, xselect.c: * xterm.c: Omit needless casts involving void * pointers and allocation. Prefer "P = xmalloc (sizeof *P)" to "P = xmalloc (sizeof (TYPE_OF_P))", as the former is more robust if P's type is changed. Prefer xzalloc to xmalloc + memset 0. Simplify malloc-or-realloc to realloc. Don't worry about xmalloc returning a null pointer. Prefer xstrdup to xmalloc + strcpy. * editfns.c (Fmessage_box): Grow message_text by at least 80 when growing it. * keyboard.c (apply_modifiers_uncached): Prefer local array to alloca of a constant.
Diffstat (limited to 'src/dispnew.c')
-rw-r--r--src/dispnew.c33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/dispnew.c b/src/dispnew.c
index 17bd2e828fa..5c6ea0123be 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -2023,9 +2023,7 @@ static struct glyph_matrix *
save_current_matrix (struct frame *f)
{
int i;
- struct glyph_matrix *saved;
-
- saved = xzalloc (sizeof *saved);
+ struct glyph_matrix *saved = xzalloc (sizeof *saved);
saved->nrows = f->current_matrix->nrows;
saved->rows = xzalloc (saved->nrows * sizeof *saved->rows);
@@ -2243,16 +2241,8 @@ adjust_frame_glyphs_for_window_redisplay (struct frame *f)
static void
adjust_frame_message_buffer (struct frame *f)
{
- ptrdiff_t size = FRAME_MESSAGE_BUF_SIZE (f) + 1;
-
- if (FRAME_MESSAGE_BUF (f))
- {
- char *buffer = FRAME_MESSAGE_BUF (f);
- char *new_buffer = (char *) xrealloc (buffer, size);
- FRAME_MESSAGE_BUF (f) = new_buffer;
- }
- else
- FRAME_MESSAGE_BUF (f) = xmalloc (size);
+ FRAME_MESSAGE_BUF (f) = xrealloc (FRAME_MESSAGE_BUF (f),
+ FRAME_MESSAGE_BUF_SIZE (f) + 1);
}
@@ -2261,9 +2251,8 @@ adjust_frame_message_buffer (struct frame *f)
static void
adjust_decode_mode_spec_buffer (struct frame *f)
{
- f->decode_mode_spec_buffer
- = (char *) xrealloc (f->decode_mode_spec_buffer,
- FRAME_MESSAGE_BUF_SIZE (f) + 1);
+ f->decode_mode_spec_buffer = xrealloc (f->decode_mode_spec_buffer,
+ FRAME_MESSAGE_BUF_SIZE (f) + 1);
}
@@ -2810,7 +2799,7 @@ mirrored_line_dance (struct glyph_matrix *matrix, int unchanged_at_top, int nlin
int i;
/* Make a copy of the original rows. */
- old_rows = (struct glyph_row *) alloca (nlines * sizeof *old_rows);
+ old_rows = alloca (nlines * sizeof *old_rows);
memcpy (old_rows, new_rows, nlines * sizeof *old_rows);
/* Assign new rows, maybe clear lines. */
@@ -2928,7 +2917,7 @@ mirror_line_dance (struct window *w, int unchanged_at_top, int nlines, int *copy
struct glyph_row *old_rows;
/* Make a copy of the original rows of matrix m. */
- old_rows = (struct glyph_row *) alloca (m->nrows * sizeof *old_rows);
+ old_rows = alloca (m->nrows * sizeof *old_rows);
memcpy (old_rows, m->rows, m->nrows * sizeof *old_rows);
for (i = 0; i < nlines; ++i)
@@ -4845,10 +4834,10 @@ scrolling (struct frame *frame)
int unchanged_at_top, unchanged_at_bottom;
int window_size;
int changed_lines;
- int *old_hash = (int *) alloca (FRAME_LINES (frame) * sizeof (int));
- int *new_hash = (int *) alloca (FRAME_LINES (frame) * sizeof (int));
- int *draw_cost = (int *) alloca (FRAME_LINES (frame) * sizeof (int));
- int *old_draw_cost = (int *) alloca (FRAME_LINES (frame) * sizeof (int));
+ int *old_hash = alloca (FRAME_LINES (frame) * sizeof (int));
+ int *new_hash = alloca (FRAME_LINES (frame) * sizeof (int));
+ int *draw_cost = alloca (FRAME_LINES (frame) * sizeof (int));
+ int *old_draw_cost = alloca (FRAME_LINES (frame) * sizeof (int));
register int i;
int free_at_end_vpos = FRAME_LINES (frame);
struct glyph_matrix *current_matrix = frame->current_matrix;