diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2012-07-05 10:32:41 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2012-07-05 10:32:41 +0400 |
commit | 23f86fce48e1cc8118f0ea5cce49d1acfd4364c4 (patch) | |
tree | 837ae05f1ad4ad92936f804d580d95751779befe /src/dispnew.c | |
parent | 0497dc44b44f148425ff76c4cb7ef0d2ead9750b (diff) | |
download | emacs-23f86fce48e1cc8118f0ea5cce49d1acfd4364c4.tar.gz |
Cleanup xmalloc.
* admin/coccinelle/xzalloc.cocci: Semantic patch to convert
calls to xmalloc with following memset to xzalloc.
* src/lisp.h (xzalloc): New prototype. Omit needless casts.
* src/alloc.c (xzalloc): New function. Omit needless casts.
* src/charset.c: Omit needless casts. Convert all calls to
malloc with following memset to xzalloc.
* src/dispnew.c: Likewise.
* src/fringe.c: Likewise.
* src/image.c: Likewise.
* src/sound.c: Likewise.
* src/term.c: Likewise.
* src/w32fns.c: Likewise.
* src/w32font.c: Likewise.
* src/w32term.c: Likewise.
* src/xfaces.c: Likewise.
* src/xfns.c: Likewise.
* src/xterm.c: Likewise.
* src/atimer.c: Omit needless casts.
* src/buffer.c: Likewise.
* src/callproc.c: Likewise.
* src/ccl.c: Likewise.
* src/coding.c: Likewise.
* src/composite.c: Likewise.
* src/doc.c: Likewise.
* src/doprnt.c: Likewise.
* src/editfns.c: Likewise.
* src/emacs.c: Likewise.
* src/eval.c: Likewise.
* src/filelock.c: Likewise.
* src/fns.c: Likewise.
* src/gtkutil.c: Likewise.
* src/keyboard.c: Likewise.
* src/lisp.h: Likewise.
* src/lread.c: Likewise.
* src/minibuf.c: Likewise.
* src/msdos.c: Likewise.
* src/print.c: Likewise.
* src/process.c: Likewise.
* src/region-cache.c: Likewise.
* src/search.c: Likewise.
* src/sysdep.c: Likewise.
* src/termcap.c: Likewise.
* src/terminal.c: Likewise.
* src/tparam.c: Likewise.
* src/w16select.c: Likewise.
* src/w32.c: Likewise.
* src/w32reg.c: Likewise.
* src/w32select.c: Likewise.
* src/w32uniscribe.c: Likewise.
* src/widget.c: Likewise.
* src/xdisp.c: Likewise.
* src/xmenu.c: Likewise.
* src/xrdb.c: Likewise.
* src/xselect.c: Likewise.
Diffstat (limited to 'src/dispnew.c')
-rw-r--r-- | src/dispnew.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/dispnew.c b/src/dispnew.c index 767f1c8112b..17bd2e828fa 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -344,11 +344,7 @@ __executable_start (void) static struct glyph_matrix * new_glyph_matrix (struct glyph_pool *pool) { - struct glyph_matrix *result; - - /* Allocate and clear. */ - result = (struct glyph_matrix *) xmalloc (sizeof *result); - memset (result, 0, sizeof *result); + struct glyph_matrix *result = xzalloc (sizeof *result); /* Increment number of allocated matrices. This count is used to detect memory leaks. */ @@ -1367,11 +1363,7 @@ row_equal_p (struct glyph_row *a, struct glyph_row *b, int mouse_face_p) static struct glyph_pool * new_glyph_pool (void) { - struct glyph_pool *result; - - /* Allocate a new glyph_pool and clear it. */ - result = (struct glyph_pool *) xmalloc (sizeof *result); - memset (result, 0, sizeof *result); + struct glyph_pool *result = xzalloc (sizeof *result); /* For memory leak and double deletion checking. */ ++glyph_pool_count; @@ -2033,19 +2025,16 @@ save_current_matrix (struct frame *f) int i; struct glyph_matrix *saved; - saved = (struct glyph_matrix *) xmalloc (sizeof *saved); - memset (saved, 0, sizeof *saved); + saved = xzalloc (sizeof *saved); saved->nrows = f->current_matrix->nrows; - saved->rows = (struct glyph_row *) xmalloc (saved->nrows - * sizeof *saved->rows); - memset (saved->rows, 0, saved->nrows * sizeof *saved->rows); + saved->rows = xzalloc (saved->nrows * sizeof *saved->rows); for (i = 0; i < saved->nrows; ++i) { struct glyph_row *from = f->current_matrix->rows + i; struct glyph_row *to = saved->rows + i; ptrdiff_t nbytes = from->used[TEXT_AREA] * sizeof (struct glyph); - to->glyphs[TEXT_AREA] = (struct glyph *) xmalloc (nbytes); + to->glyphs[TEXT_AREA] = xmalloc (nbytes); memcpy (to->glyphs[TEXT_AREA], from->glyphs[TEXT_AREA], nbytes); to->used[TEXT_AREA] = from->used[TEXT_AREA]; } @@ -2263,7 +2252,7 @@ adjust_frame_message_buffer (struct frame *f) FRAME_MESSAGE_BUF (f) = new_buffer; } else - FRAME_MESSAGE_BUF (f) = (char *) xmalloc (size); + FRAME_MESSAGE_BUF (f) = xmalloc (size); } |