emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r108876: Cleanup xmalloc.


From: Dmitry Antipov
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108876: Cleanup xmalloc.
Date: Thu, 05 Jul 2012 10:32:41 +0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108876
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Thu 2012-07-05 10:32:41 +0400
message:
  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.
added:
  admin/coccinelle/xzalloc.cocci
modified:
  admin/ChangeLog
  src/ChangeLog
  src/alloc.c
  src/atimer.c
  src/buffer.c
  src/callproc.c
  src/ccl.c
  src/charset.c
  src/coding.c
  src/composite.c
  src/dispnew.c
  src/doc.c
  src/doprnt.c
  src/editfns.c
  src/emacs.c
  src/eval.c
  src/filelock.c
  src/fns.c
  src/fringe.c
  src/gtkutil.c
  src/image.c
  src/keyboard.c
  src/lisp.h
  src/lread.c
  src/minibuf.c
  src/msdos.c
  src/print.c
  src/process.c
  src/region-cache.c
  src/search.c
  src/sound.c
  src/sysdep.c
  src/term.c
  src/termcap.c
  src/terminal.c
  src/tparam.c
  src/w16select.c
  src/w32.c
  src/w32fns.c
  src/w32font.c
  src/w32reg.c
  src/w32select.c
  src/w32term.c
  src/w32uniscribe.c
  src/widget.c
  src/xdisp.c
  src/xfaces.c
  src/xfns.c
  src/xmenu.c
  src/xrdb.c
  src/xselect.c
  src/xterm.c
=== modified file 'admin/ChangeLog'
--- a/admin/ChangeLog   2012-07-04 16:46:42 +0000
+++ b/admin/ChangeLog   2012-07-05 06:32:41 +0000
@@ -1,3 +1,8 @@
+2012-07-05  Dmitry Antipov  <address@hidden>
+
+       * coccinelle/xzalloc.cocci: Semantic patch to convert
+       calls to xmalloc with following memset to xzalloc.
+
 2012-07-04  Juanma Barranquero  <address@hidden>
 
        * CPP-DEFINES (LISP_FLOAT_TYPE): Remove, obsolete.

=== added file 'admin/coccinelle/xzalloc.cocci'
--- a/admin/coccinelle/xzalloc.cocci    1970-01-01 00:00:00 +0000
+++ b/admin/coccinelle/xzalloc.cocci    2012-07-05 06:32:41 +0000
@@ -0,0 +1,10 @@
+@@
+expression x;
+expression E;
+@@
+ x = 
+- xmalloc 
++ xzalloc
+  (E)
+  ... 
+- memset (x, 0, E);

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-07-05 04:16:11 +0000
+++ b/src/ChangeLog     2012-07-05 06:32:41 +0000
@@ -1,3 +1,59 @@
+2012-07-05  Dmitry Antipov  <address@hidden>
+
+       Cleanup xmalloc.
+       * lisp.h (xzalloc): New prototype.  Omit needless casts.
+       * alloc.c (xzalloc): New function.  Omit needless casts.
+       * charset.c: Omit needless casts.  Convert all calls to
+       xmalloc with following memset to xzalloc.
+       * dispnew.c: Likewise.
+       * fringe.c: Likewise.
+       * image.c: Likewise.
+       * sound.c: Likewise.
+       * term.c: Likewise.
+       * w32fns.c: Likewise.
+       * w32font.c: Likewise.
+       * w32term.c: Likewise.
+       * xfaces.c: Likewise.
+       * xfns.c: Likewise.
+       * xterm.c: Likewise.
+       * atimer.c: Omit needless casts.
+       * buffer.c: Likewise.
+       * callproc.c: Likewise.
+       * ccl.c: Likewise.
+       * coding.c: Likewise.
+       * composite.c: Likewise.
+       * doc.c: Likewise.
+       * doprnt.c: Likewise.
+       * editfns.c: Likewise.
+       * emacs.c: Likewise.
+       * eval.c: Likewise.
+       * filelock.c: Likewise.
+       * fns.c: Likewise.
+       * gtkutil.c: Likewise.
+       * keyboard.c: Likewise.
+       * lisp.h: Likewise.
+       * lread.c: Likewise.
+       * minibuf.c: Likewise.
+       * msdos.c: Likewise.
+       * print.c: Likewise.
+       * process.c: Likewise.
+       * region-cache.c: Likewise.
+       * search.c: Likewise.
+       * sysdep.c: Likewise.
+       * termcap.c: Likewise.
+       * terminal.c: Likewise.
+       * tparam.c: Likewise.
+       * w16select.c: Likewise.
+       * w32.c: Likewise.
+       * w32reg.c: Likewise.
+       * w32select.c: Likewise.
+       * w32uniscribe.c: Likewise.
+       * widget.c: Likewise.
+       * xdisp.c: Likewise.
+       * xmenu.c: Likewise.
+       * xrdb.c: Likewise.
+       * xselect.c: Likewise.
+
 2012-07-05  Paul Eggert  <address@hidden>
 
        * fileio.c (time_error_value): Check the right error number.

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2012-07-04 16:52:51 +0000
+++ b/src/alloc.c       2012-07-05 06:32:41 +0000
@@ -735,6 +735,22 @@
   return val;
 }
 
+/* Like the above, but zeroes out the memory just allocated.  */
+
+void *
+xzalloc (size_t size)
+{
+  void *val;
+
+  MALLOC_BLOCK_INPUT;
+  val = malloc (size);
+  MALLOC_UNBLOCK_INPUT;
+
+  if (!val && size)
+    memory_full (size);
+  memset (val, 0, size);
+  return val;
+}
 
 /* Like realloc but check for no memory and block interrupt input..  */
 
@@ -867,7 +883,7 @@
 xstrdup (const char *s)
 {
   size_t len = strlen (s) + 1;
-  char *p = (char *) xmalloc (len);
+  char *p = xmalloc (len);
   memcpy (p, s, len);
   return p;
 }
@@ -3881,7 +3897,7 @@
   if (x == NULL)
     abort ();
 #else
-  x = (struct mem_node *) xmalloc (sizeof *x);
+  x = xmalloc (sizeof *x);
 #endif
   x->start = start;
   x->end = end;
@@ -5047,7 +5063,7 @@
   /* Don't allocate a large amount here,
      because it might get mmap'd and then its address
      might not be usable.  */
-  purebeg = (char *) xmalloc (10000);
+  purebeg = xmalloc (10000);
   pure_size = 10000;
   pure_bytes_used_before_overflow += pure_bytes_used - size;
   pure_bytes_used = 0;

=== modified file 'src/atimer.c'
--- a/src/atimer.c      2012-06-22 21:17:42 +0000
+++ b/src/atimer.c      2012-07-05 06:32:41 +0000
@@ -107,7 +107,7 @@
       free_atimers = t->next;
     }
   else
-    t = (struct atimer *) xmalloc (sizeof *t);
+    t = xmalloc (sizeof *t);
 
   /* Fill the atimer structure.  */
   memset (t, 0, sizeof *t);

=== modified file 'src/buffer.c'
--- a/src/buffer.c      2012-07-04 15:49:46 +0000
+++ b/src/buffer.c      2012-07-05 06:32:41 +0000
@@ -3893,7 +3893,7 @@
 
   len = 10;
   /* We can't use alloca here because overlays_at can call xrealloc.  */
-  overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object));
+  overlay_vec = xmalloc (len * sizeof (Lisp_Object));
 
   /* Put all the overlays we want in a vector in overlay_vec.
      Store the length in len.  */
@@ -3924,7 +3924,7 @@
   CHECK_NUMBER_COERCE_MARKER (end);
 
   len = 10;
-  overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object));
+  overlay_vec = xmalloc (len * sizeof (Lisp_Object));
 
   /* Put all the overlays we want in a vector in overlay_vec.
      Store the length in len.  */
@@ -3952,7 +3952,7 @@
   CHECK_NUMBER_COERCE_MARKER (pos);
 
   len = 10;
-  overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object));
+  overlay_vec = xmalloc (len * sizeof (Lisp_Object));
 
   /* Put all the overlays we want in a vector in overlay_vec.
      Store the length in len.
@@ -3996,7 +3996,7 @@
     return pos;
 
   len = 10;
-  overlay_vec = (Lisp_Object *) xmalloc (len * sizeof (Lisp_Object));
+  overlay_vec = xmalloc (len * sizeof (Lisp_Object));
 
   /* Put all the overlays we want in a vector in overlay_vec.
      Store the length in len.

=== modified file 'src/callproc.c'
--- a/src/callproc.c    2012-07-03 18:24:42 +0000
+++ b/src/callproc.c    2012-07-05 06:32:41 +0000
@@ -1172,7 +1172,7 @@
     /* MSDOS must have all environment variables malloc'ed, because
        low-level libc functions that launch subsidiary processes rely
        on that.  */
-    pwd_var = (char *) xmalloc (i + 6);
+    pwd_var = xmalloc (i + 6);
 #else
     pwd_var = (char *) alloca (i + 6);
 #endif

=== modified file 'src/ccl.c'
--- a/src/ccl.c 2012-06-26 02:33:51 +0000
+++ b/src/ccl.c 2012-07-05 06:32:41 +0000
@@ -2098,7 +2098,7 @@
   outbufsize = (ccl.buf_magnification
                ? str_bytes * ccl.buf_magnification + 256
                : str_bytes + 256);
-  outp = outbuf = (unsigned char *) xmalloc (outbufsize);
+  outp = outbuf = xmalloc (outbufsize);
 
   consumed_chars = consumed_bytes = 0;
   produced_chars = 0;

=== modified file 'src/charset.c'
--- a/src/charset.c     2012-06-30 09:13:54 +0000
+++ b/src/charset.c     2012-07-05 06:32:41 +0000
@@ -912,8 +912,7 @@
 
   if (! charset.code_linear_p)
     {
-      charset.code_space_mask = (unsigned char *) xmalloc (256);
-      memset (charset.code_space_mask, 0, 256);
+      charset.code_space_mask = xzalloc (256);
       for (i = 0; i < 4; i++)
        for (j = charset.code_space[i * 4]; j <= charset.code_space[i * 4 + 1];
             j++)

=== modified file 'src/coding.c'
--- a/src/coding.c      2012-06-19 16:56:28 +0000
+++ b/src/coding.c      2012-07-05 06:32:41 +0000
@@ -8006,7 +8006,7 @@
     {
       ptrdiff_t dst_bytes = max (1, coding->src_chars);
       coding->dst_object = Qnil;
-      coding->destination = (unsigned char *) xmalloc (dst_bytes);
+      coding->destination = xmalloc (dst_bytes);
       coding->dst_bytes = dst_bytes;
       coding->dst_multibyte = 0;
     }

=== modified file 'src/composite.c'
--- a/src/composite.c   2012-07-03 18:24:42 +0000
+++ b/src/composite.c   2012-07-05 06:32:41 +0000
@@ -326,7 +326,7 @@
     memory_full (SIZE_MAX);
 
   /* Register the composition in composition_table.  */
-  cmp = (struct composition *) xmalloc (sizeof (struct composition));
+  cmp = xmalloc (sizeof (struct composition));
 
   cmp->method = method;
   cmp->hash_index = hash_index;

=== modified file 'src/dispnew.c'
--- a/src/dispnew.c     2012-06-28 07:50:50 +0000
+++ b/src/dispnew.c     2012-07-05 06:32:41 +0000
@@ -344,11 +344,7 @@
 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 @@
 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 @@
   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 @@
       FRAME_MESSAGE_BUF (f) = new_buffer;
     }
   else
-    FRAME_MESSAGE_BUF (f) = (char *) xmalloc (size);
+    FRAME_MESSAGE_BUF (f) = xmalloc (size);
 }
 
 

=== modified file 'src/doc.c'
--- a/src/doc.c 2012-07-03 18:24:42 +0000
+++ b/src/doc.c 2012-07-05 06:32:41 +0000
@@ -757,7 +757,7 @@
     keymap = Voverriding_local_map;
 
   bsize = SBYTES (string);
-  bufp = buf = (char *) xmalloc (bsize);
+  bufp = buf = xmalloc (bsize);
 
   strp = SDATA (string);
   while (strp < SDATA (string) + SBYTES (string))

=== modified file 'src/doprnt.c'
--- a/src/doprnt.c      2012-07-04 08:26:20 +0000
+++ b/src/doprnt.c      2012-07-05 06:32:41 +0000
@@ -257,7 +257,7 @@
            {
              if (big_buffer)
                xfree (big_buffer);
-             big_buffer = (char *) xmalloc (size_bound);
+             big_buffer = xmalloc (size_bound);
              sprintf_buffer = big_buffer;
              size_allocated = size_bound;
            }

=== modified file 'src/editfns.c'
--- a/src/editfns.c     2012-07-03 18:24:42 +0000
+++ b/src/editfns.c     2012-07-05 06:32:41 +0000
@@ -2157,8 +2157,8 @@
   for (from = environ; *from; from++)
     continue;
   envptrs = from - environ + 2;
-  newenv = to = (char **) xmalloc (envptrs * sizeof (char *)
-                                  + (tzstring ? strlen (tzstring) + 4 : 0));
+  newenv = to = xmalloc (envptrs * sizeof (char *)
+                        + (tzstring ? strlen (tzstring) + 4 : 0));
 
   /* Add TZSTRING to the end of environ, as a value for TZ.  */
   if (tzstring)
@@ -3477,7 +3477,7 @@
       /* Copy the data so that it won't move when we GC.  */
       if (! message_text)
        {
-         message_text = (char *)xmalloc (80);
+         message_text = xmalloc (80);
          message_length = 80;
        }
       if (SBYTES (val) > message_length)

=== modified file 'src/emacs.c'
--- a/src/emacs.c       2012-07-04 17:04:09 +0000
+++ b/src/emacs.c       2012-07-05 06:32:41 +0000
@@ -1820,7 +1820,7 @@
 static void
 sort_args (int argc, char **argv)
 {
-  char **new = (char **) xmalloc (sizeof (char *) * argc);
+  char **new = xmalloc (sizeof (char *) * argc);
   /* For each element of argv,
      the corresponding element of options is:
      0 for an option that takes no arguments,

=== modified file 'src/eval.c'
--- a/src/eval.c        2012-07-03 18:24:42 +0000
+++ b/src/eval.c        2012-07-05 06:32:41 +0000
@@ -138,7 +138,7 @@
 init_eval_once (void)
 {
   enum { size = 50 };
-  specpdl = (struct specbinding *) xmalloc (size * sizeof (struct 
specbinding));
+  specpdl = xmalloc (size * sizeof (struct specbinding));
   specpdl_size = size;
   specpdl_ptr = specpdl;
   /* Don't forget to update docs (lispref node "Local Variables").  */

=== modified file 'src/filelock.c'
--- a/src/filelock.c    2012-06-16 12:24:15 +0000
+++ b/src/filelock.c    2012-07-05 06:32:41 +0000
@@ -422,7 +422,7 @@
       return -1;
     }
   len = at - lfinfo;
-  owner->user = (char *) xmalloc (len + 1);
+  owner->user = xmalloc (len + 1);
   memcpy (owner->user, lfinfo, len);
   owner->user[len] = 0;
 
@@ -449,7 +449,7 @@
 
   /* The host is everything in between.  */
   len = dot - at - 1;
-  owner->host = (char *) xmalloc (len + 1);
+  owner->host = xmalloc (len + 1);
   memcpy (owner->host, at + 1, len);
   owner->host[len] = 0;
 

=== modified file 'src/fns.c'
--- a/src/fns.c 2012-07-04 14:38:02 +0000
+++ b/src/fns.c 2012-07-05 06:32:41 +0000
@@ -1018,7 +1018,7 @@
   if (STRING_MULTIBYTE (string))
     {
       ptrdiff_t bytes = SBYTES (string);
-      unsigned char *str = (unsigned char *) xmalloc (bytes);
+      unsigned char *str = xmalloc (bytes);
 
       memcpy (str, SDATA (string), bytes);
       bytes = str_as_unibyte (str, bytes);
@@ -1100,7 +1100,7 @@
   if (STRING_MULTIBYTE (string))
     {
       ptrdiff_t chars = SCHARS (string);
-      unsigned char *str = (unsigned char *) xmalloc (chars);
+      unsigned char *str = xmalloc (chars);
       ptrdiff_t converted = str_to_unibyte (SDATA (string), str, chars, 0);
 
       if (converted < chars)

=== modified file 'src/fringe.c'
--- a/src/fringe.c      2012-06-28 07:50:27 +0000
+++ b/src/fringe.c      2012-07-05 06:32:41 +0000
@@ -1639,8 +1639,7 @@
 
   fb.dynamic = 1;
 
-  xfb = (struct fringe_bitmap *) xmalloc (sizeof fb
-                                         + fb.height * BYTES_PER_BITMAP_ROW);
+  xfb = xmalloc (sizeof fb + fb.height * BYTES_PER_BITMAP_ROW);
   fb.bits = b = (unsigned short *) (xfb + 1);
   memset (b, 0, fb.height);
 
@@ -1805,15 +1804,11 @@
   max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20;
 
   fringe_bitmaps
-    = (struct fringe_bitmap **) xmalloc (max_fringe_bitmaps * sizeof (struct 
fringe_bitmap *));
-  fringe_faces
-    = (Lisp_Object *) xmalloc (max_fringe_bitmaps * sizeof (Lisp_Object));
+    = xzalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *));
+  fringe_faces = xmalloc (max_fringe_bitmaps * sizeof (Lisp_Object));
 
   for (i = 0; i < max_fringe_bitmaps; i++)
-    {
-      fringe_bitmaps[i] = NULL;
-      fringe_faces[i] = Qnil;
-    }
+    fringe_faces[i] = Qnil;
 }
 
 #ifdef HAVE_NTGUI

=== modified file 'src/gtkutil.c'
--- a/src/gtkutil.c     2012-06-28 07:50:27 +0000
+++ b/src/gtkutil.c     2012-07-05 06:32:41 +0000
@@ -209,7 +209,7 @@
     }
   else
     {
-      wv = (widget_value *) xmalloc (sizeof (widget_value));
+      wv = xmalloc (sizeof (widget_value));
       malloc_cpt++;
     }
   memset (wv, 0, sizeof (widget_value));
@@ -2042,7 +2042,7 @@
 {
   if (! cl_data)
     {
-      cl_data = (xg_menu_cb_data*) xmalloc (sizeof (*cl_data));
+      cl_data = xmalloc (sizeof (*cl_data));
       cl_data->f = f;
       cl_data->menu_bar_vector = f->menu_bar_vector;
       cl_data->menu_bar_items_used = f->menu_bar_items_used;

=== modified file 'src/image.c'
--- a/src/image.c       2012-07-03 18:24:42 +0000
+++ b/src/image.c       2012-07-05 06:32:41 +0000
@@ -319,7 +319,7 @@
   id = x_allocate_bitmap_record (f);
   dpyinfo->bitmaps[id - 1].img = bitmap;
   dpyinfo->bitmaps[id - 1].refcount = 1;
-  dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1);
+  dpyinfo->bitmaps[id - 1].file = xmalloc (SBYTES (file) + 1);
   dpyinfo->bitmaps[id - 1].depth = 1;
   dpyinfo->bitmaps[id - 1].height = ns_image_width (bitmap);
   dpyinfo->bitmaps[id - 1].width = ns_image_height (bitmap);
@@ -365,7 +365,7 @@
   dpyinfo->bitmaps[id - 1].pixmap = bitmap;
   dpyinfo->bitmaps[id - 1].have_mask = 0;
   dpyinfo->bitmaps[id - 1].refcount = 1;
-  dpyinfo->bitmaps[id - 1].file = (char *) xmalloc (SBYTES (file) + 1);
+  dpyinfo->bitmaps[id - 1].file = xmalloc (SBYTES (file) + 1);
   dpyinfo->bitmaps[id - 1].depth = 1;
   dpyinfo->bitmaps[id - 1].height = height;
   dpyinfo->bitmaps[id - 1].width = width;
@@ -599,7 +599,7 @@
     {
       /* Make a copy of TYPE to avoid a bus error in a dumped Emacs.
          The initialized data segment is read-only.  */
-      struct image_type *p = (struct image_type *) xmalloc (sizeof *p);
+      struct image_type *p = xmalloc (sizeof *p);
       memcpy (p, type, sizeof *p);
       p->next = image_types;
       image_types = p;
@@ -982,11 +982,10 @@
 static struct image *
 make_image (Lisp_Object spec, EMACS_UINT hash)
 {
-  struct image *img = (struct image *) xmalloc (sizeof *img);
+  struct image *img = xzalloc (sizeof *img);
   Lisp_Object file = image_spec_value (spec, QCfile, NULL);
 
   eassert (valid_image_p (spec));
-  memset (img, 0, sizeof *img);
   img->dependencies = NILP (file) ? Qnil : list1 (file);
   img->type = lookup_image_type (image_spec_value (spec, QCtype, NULL));
   eassert (img->type != NULL);
@@ -1385,16 +1384,14 @@
 struct image_cache *
 make_image_cache (void)
 {
-  struct image_cache *c = (struct image_cache *) xmalloc (sizeof *c);
+  struct image_cache *c = xzalloc (sizeof *c);
   int size;
 
-  memset (c, 0, sizeof *c);
   size = 50;
-  c->images = (struct image **) xmalloc (size * sizeof *c->images);
+  c->images = xmalloc (size * sizeof *c->images);
   c->size = size;
   size = IMAGE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
-  c->buckets = (struct image **) xmalloc (size);
-  memset (c->buckets, 0, size);
+  c->buckets = xzalloc (size);
   return c;
 }
 
@@ -1969,7 +1966,7 @@
     }
 
   /* Allocate image raster.  */
-  (*ximg)->data = (char *) xmalloc ((*ximg)->bytes_per_line * height);
+  (*ximg)->data = xmalloc ((*ximg)->bytes_per_line * height);
 
   /* Allocate a pixmap of the same size.  */
   *pixmap = XCreatePixmap (display, window, width, height, depth);
@@ -2183,7 +2180,7 @@
   if (stat (file, &st) == 0
       && (fp = fopen (file, "rb")) != NULL
       && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX)
-      && (buf = (unsigned char *) xmalloc (st.st_size),
+      && (buf = xmalloc (st.st_size),
          fread (buf, 1, st.st_size, fp) == st.st_size))
     {
       *size = st.st_size;
@@ -2705,7 +2702,7 @@
     }
   bytes_per_line = (*width + 7) / 8 + padding_p;
   nbytes = bytes_per_line * *height;
-  p = *data = (char *) xmalloc (nbytes);
+  p = *data = xmalloc (nbytes);
 
   if (v10)
     {
@@ -3118,8 +3115,7 @@
 xpm_init_color_cache (struct frame *f, XpmAttributes *attrs)
 {
   size_t nbytes = XPM_COLOR_CACHE_BUCKETS * sizeof *xpm_color_cache;
-  xpm_color_cache = (struct xpm_cached_color **) xmalloc (nbytes);
-  memset (xpm_color_cache, 0, nbytes);
+  xpm_color_cache = xzalloc (nbytes);
   init_color_table ();
 
   if (attrs->valuemask & XpmColorSymbols)
@@ -3183,7 +3179,7 @@
     bucket = xpm_color_bucket (color_name);
 
   nbytes = offsetof (struct xpm_cached_color, name) + strlen (color_name) + 1;
-  p = (struct xpm_cached_color *) xmalloc (nbytes);
+  p = xmalloc (nbytes);
   strcpy (p->name, color_name);
   p->color = *color;
   p->next = xpm_color_cache[bucket];
@@ -4154,8 +4150,7 @@
 init_color_table (void)
 {
   int size = CT_SIZE * sizeof (*ct_table);
-  ct_table = (struct ct_color **) xmalloc (size);
-  memset (ct_table, 0, size);
+  ct_table = xzalloc (size);
   ct_colors_allocated = 0;
 }
 
@@ -4250,7 +4245,7 @@
       if (rc)
        {
          ++ct_colors_allocated;
-         p = (struct ct_color *) xmalloc (sizeof *p);
+         p = xmalloc (sizeof *p);
          p->r = r;
          p->g = g;
          p->b = b;
@@ -4268,7 +4263,7 @@
       color = RGB_TO_ULONG (r, g, b);
 #endif /* HAVE_NTGUI */
       ++ct_colors_allocated;
-      p = (struct ct_color *) xmalloc (sizeof *p);
+      p = xmalloc (sizeof *p);
       p->r = r;
       p->g = g;
       p->b = b;
@@ -4323,7 +4318,7 @@
        {
          ++ct_colors_allocated;
 
-         p = (struct ct_color *) xmalloc (sizeof *p);
+         p = xmalloc (sizeof *p);
          p->r = color.red;
          p->g = color.green;
          p->b = color.blue;
@@ -4355,8 +4350,7 @@
     }
   else
     {
-      colors = (unsigned long *) xmalloc (ct_colors_allocated
-                                         * sizeof *colors);
+      colors = xmalloc (ct_colors_allocated * sizeof *colors);
       *n = ct_colors_allocated;
 
       for (i = j = 0; i < CT_SIZE; ++i)
@@ -4445,7 +4439,7 @@
 
   if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *colors / img->width < img->height)
     memory_full (SIZE_MAX);
-  colors = (XColor *) xmalloc (sizeof *colors * img->width * img->height);
+  colors = xmalloc (sizeof *colors * img->width * img->height);
 
 #ifndef HAVE_NTGUI
   /* Get the X image IMG->pixmap.  */
@@ -4599,7 +4593,7 @@
 
   if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *new / img->width < img->height)
     memory_full (SIZE_MAX);
-  new = (XColor *) xmalloc (sizeof *new * img->width * img->height);
+  new = xmalloc (sizeof *new * img->width * img->height);
 
   for (y = 0; y < img->height; ++y)
     {
@@ -4852,8 +4846,7 @@
 #else
   /* Create the bit array serving as mask.  */
   row_width = (img->width + 7) / 8;
-  mask_img = xmalloc (row_width * img->height);
-  memset (mask_img, 0, row_width * img->height);
+  mask_img = xzalloc (row_width * img->height);
 
   /* Create a memory device context for IMG->pixmap.  */
   frame_dc = get_frame_dc (f);
@@ -5069,7 +5062,7 @@
   if (stat (SDATA (file), &st) == 0
       && (fp = fopen (SDATA (file), "rb")) != NULL
       && 0 <= st.st_size && st.st_size <= min (PTRDIFF_MAX, SIZE_MAX)
-      && (buf = (char *) xmalloc (st.st_size),
+      && (buf = xmalloc (st.st_size),
          fread (buf, 1, st.st_size, fp) == st.st_size))
     {
       *size = st.st_size;
@@ -5840,8 +5833,8 @@
   if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof *rows < height
       || min (PTRDIFF_MAX, SIZE_MAX) / sizeof *pixels / height < row_bytes)
     memory_full (SIZE_MAX);
-  pixels = (png_byte *) xmalloc (sizeof *pixels * row_bytes * height);
-  rows = (png_byte **) xmalloc (height * sizeof *rows);
+  pixels = xmalloc (sizeof *pixels * row_bytes * height);
+  rows = xmalloc (height * sizeof *rows);
   for (i = 0; i < height; ++i)
     rows[i] = pixels + i * row_bytes;
 
@@ -6890,7 +6883,7 @@
       return 0;
     }
 
-  buf = (uint32 *) xmalloc (sizeof *buf * width * height);
+  buf = xmalloc (sizeof *buf * width * height);
 
   rc = fn_TIFFReadRGBAImage (tiff, width, height, buf, 0);
 

=== modified file 'src/keyboard.c'
--- a/src/keyboard.c    2012-07-03 18:24:42 +0000
+++ b/src/keyboard.c    2012-07-05 06:32:41 +0000
@@ -884,8 +884,7 @@
 void
 push_kboard (struct kboard *k)
 {
-  struct kboard_stack *p
-    = (struct kboard_stack *) xmalloc (sizeof (struct kboard_stack));
+  struct kboard_stack *p = xmalloc (sizeof (struct kboard_stack));
 
   p->next = kboard_stack;
   p->kboard = current_kboard;
@@ -8323,7 +8322,7 @@
       const char *capt = STRINGP (tcapt) ? SSDATA (tcapt) : "";
       ptrdiff_t max_lbl =
        2 * max (0, min (tool_bar_max_label_size, STRING_BYTES_BOUND / 2));
-      char *buf = (char *) xmalloc (max_lbl + 1);
+      char *buf = xmalloc (max_lbl + 1);
       Lisp_Object new_lbl;
       ptrdiff_t caption_len = strlen (capt);
 
@@ -12188,7 +12187,7 @@
   Vdebug_on_event = intern_c_string ("sigusr2");
 
   /* Create the initial keyboard.  */
-  initial_kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+  initial_kboard = xmalloc (sizeof (KBOARD));
   init_kboard (initial_kboard);
   /* Vwindow_system is left at t for now.  */
   initial_kboard->next_kboard = all_kboards;

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2012-07-04 14:38:02 +0000
+++ b/src/lisp.h        2012-07-05 06:32:41 +0000
@@ -3237,6 +3237,7 @@
 extern int immediate_quit;         /* Nonzero means ^G can quit instantly */
 
 extern void *xmalloc (size_t);
+extern void *xzalloc (size_t);
 extern void *xrealloc (void *, size_t);
 extern void xfree (void *);
 extern void *xnmalloc (ptrdiff_t, ptrdiff_t);
@@ -3352,7 +3353,7 @@
       buf = (type) alloca (size);                        \
     else                                                 \
       {                                                          \
-       buf = (type) xmalloc (size);                      \
+       buf = xmalloc (size);                             \
        sa_must_free = 1;                                 \
        record_unwind_protect (safe_alloca_unwind,        \
                               make_save_value (buf, 0)); \
@@ -3396,7 +3397,7 @@
     else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object)) \
       {                                                          \
        Lisp_Object arg_;                                 \
-       buf = (Lisp_Object *) xmalloc ((nelt) * sizeof (Lisp_Object));  \
+       buf = xmalloc ((nelt) * sizeof (Lisp_Object));    \
        arg_ = make_save_value (buf, nelt);               \
        XSAVE_VALUE (arg_)->dogc = 1;                     \
        sa_must_free = 1;                                 \

=== modified file 'src/lread.c'
--- a/src/lread.c       2012-07-04 00:04:46 +0000
+++ b/src/lread.c       2012-07-05 06:32:41 +0000
@@ -2625,7 +2625,7 @@
 
              if (saved_doc_string_size == 0)
                {
-                 saved_doc_string = (char *) xmalloc (nskip + extra);
+                 saved_doc_string = xmalloc (nskip + extra);
                  saved_doc_string_size = nskip + extra;
                }
              if (nskip > saved_doc_string_size)
@@ -3966,7 +3966,7 @@
 
   DEFSYM (Qvariable_documentation, "variable-documentation");
 
-  read_buffer = (char *) xmalloc (size);
+  read_buffer = xmalloc (size);
   read_buffer_size = size;
 }
 

=== modified file 'src/minibuf.c'
--- a/src/minibuf.c     2012-06-28 12:29:37 +0000
+++ b/src/minibuf.c     2012-07-05 06:32:41 +0000
@@ -248,7 +248,7 @@
   val = Qnil;
   size = 100;
   len = 0;
-  line = (char *) xmalloc (size);
+  line = xmalloc (size);
 
   while ((c = getchar ()) != '\n')
     {

=== modified file 'src/msdos.c'
--- a/src/msdos.c       2012-07-02 08:00:05 +0000
+++ b/src/msdos.c       2012-07-05 06:32:41 +0000
@@ -2828,7 +2828,7 @@
 {
   XMenu *menu;
 
-  menu = (XMenu *) xmalloc (sizeof (XMenu));
+  menu = xmalloc (sizeof (XMenu));
   menu->allocated = menu->count = menu->panecount = menu->width = 0;
   return menu;
 }
@@ -2842,10 +2842,10 @@
   if (menu->allocated == 0)
     {
       int count = menu->allocated = 10;
-      menu->text = (char **) xmalloc (count * sizeof (char *));
-      menu->submenu = (XMenu **) xmalloc (count * sizeof (XMenu *));
-      menu->panenumber = (int *) xmalloc (count * sizeof (int));
-      menu->help_text = (const char **) xmalloc (count * sizeof (char *));
+      menu->text = xmalloc (count * sizeof (char *));
+      menu->submenu = xmalloc (count * sizeof (XMenu *));
+      menu->panenumber = xmalloc (count * sizeof (int));
+      menu->help_text = xmalloc (count * sizeof (char *));
     }
   else if (menu->allocated == menu->count)
     {
@@ -2926,7 +2926,7 @@
   width = menu->width;
   /* We multiply width by 2 to account for possible control characters.
      FIXME: cater to non-ASCII characters in menus.  */
-  text = (struct glyph *) xmalloc ((width * 2 + 2) * sizeof (struct glyph));
+  text = xmalloc ((width * 2 + 2) * sizeof (struct glyph));
   ScreenGetCursor (&row, &col);
   mouse_get_xy (&mx, &my);
   IT_update_begin (sf);

=== modified file 'src/print.c'
--- a/src/print.c       2012-06-28 11:11:48 +0000
+++ b/src/print.c       2012-07-05 06:32:41 +0000
@@ -157,7 +157,7 @@
        else                                                            \
         {                                                              \
           int new_size = 1000;                                         \
-          print_buffer = (char *) xmalloc (new_size);                  \
+          print_buffer = xmalloc (new_size);                           \
           print_buffer_size = new_size;                                \
           free_print_buffer = 1;                                       \
         }                                                              \

=== modified file 'src/process.c'
--- a/src/process.c     2012-07-03 18:24:42 +0000
+++ b/src/process.c     2012-07-05 06:32:41 +0000
@@ -3316,7 +3316,7 @@
        {
          if (datagram_address[s].sa)
            abort ();
-         datagram_address[s].sa = (struct sockaddr *) xmalloc 
(lres->ai_addrlen);
+         datagram_address[s].sa = xmalloc (lres->ai_addrlen);
          datagram_address[s].len = lres->ai_addrlen;
          if (is_server)
            {
@@ -6286,7 +6286,7 @@
 
       if (!proc_encode_coding_system[new_outfd])
        proc_encode_coding_system[new_outfd]
-         = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+         = xmalloc (sizeof (struct coding_system));
       memcpy (proc_encode_coding_system[new_outfd],
              proc_encode_coding_system[old_outfd],
              sizeof (struct coding_system));
@@ -7084,7 +7084,7 @@
 
   if (!proc_decode_coding_system[inch])
     proc_decode_coding_system[inch]
-      = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+      = xmalloc (sizeof (struct coding_system));
   coding_system = p->decode_coding_system;
   if (! NILP (p->filter))
     ;
@@ -7097,7 +7097,7 @@
 
   if (!proc_encode_coding_system[outch])
     proc_encode_coding_system[outch]
-      = (struct coding_system *) xmalloc (sizeof (struct coding_system));
+      = xmalloc (sizeof (struct coding_system));
   setup_coding_system (p->encode_coding_system,
                       proc_encode_coding_system[outch]);
 #endif

=== modified file 'src/region-cache.c'
--- a/src/region-cache.c        2012-06-16 12:24:15 +0000
+++ b/src/region-cache.c        2012-07-05 06:32:41 +0000
@@ -132,15 +132,13 @@
 struct region_cache *
 new_region_cache (void)
 {
-  struct region_cache *c
-    = (struct region_cache *) xmalloc (sizeof (struct region_cache));
+  struct region_cache *c = xmalloc (sizeof (struct region_cache));
 
   c->gap_start = 0;
   c->gap_len = NEW_CACHE_GAP;
   c->cache_len = 0;
-  c->boundaries =
-    (struct boundary *) xmalloc ((c->gap_len + c->cache_len)
-                                 * sizeof (*c->boundaries));
+  c->boundaries = xmalloc ((c->gap_len + c->cache_len)
+                          * sizeof (*c->boundaries));
 
   c->beg_unchanged = 0;
   c->end_unchanged = 0;

=== modified file 'src/search.c'
--- a/src/search.c      2012-07-04 08:07:26 +0000
+++ b/src/search.c      2012-07-05 06:32:41 +0000
@@ -2064,8 +2064,8 @@
      the match position.  */
   if (search_regs.num_regs == 0)
     {
-      search_regs.start = (regoff_t *) xmalloc (2 * sizeof (regoff_t));
-      search_regs.end = (regoff_t *) xmalloc (2 * sizeof (regoff_t));
+      search_regs.start = xmalloc (2 * sizeof (regoff_t));
+      search_regs.end = xmalloc (2 * sizeof (regoff_t));
       search_regs.num_regs = 2;
     }
 
@@ -2500,7 +2500,7 @@
       substed_alloc_size = ((STRING_BYTES_BOUND - 100) / 2 < length
                            ? STRING_BYTES_BOUND
                            : length * 2 + 100);
-      substed = (unsigned char *) xmalloc (substed_alloc_size);
+      substed = xmalloc (substed_alloc_size);
       substed_len = 0;
 
       /* Go thru NEWTEXT, producing the actual text to insert in
@@ -3040,7 +3040,7 @@
   for (i = 0; i < REGEXP_CACHE_SIZE; ++i)
     {
       searchbufs[i].buf.allocated = 100;
-      searchbufs[i].buf.buffer = (unsigned char *) xmalloc (100);
+      searchbufs[i].buf.buffer = xmalloc (100);
       searchbufs[i].buf.fastmap = searchbufs[i].fastmap;
       searchbufs[i].regexp = Qnil;
       searchbufs[i].whitespace_regexp = Qnil;

=== modified file 'src/sound.c'
--- a/src/sound.c       2012-06-28 07:50:27 +0000
+++ b/src/sound.c       2012-07-05 06:32:41 +0000
@@ -1364,10 +1364,8 @@
 #ifndef WINDOWSNT
   file = Qnil;
   GCPRO2 (sound, file);
-  current_sound_device = (struct sound_device *) xmalloc (sizeof (struct 
sound_device));
-  memset (current_sound_device, 0, sizeof (struct sound_device));
-  current_sound = (struct sound *) xmalloc (sizeof (struct sound));
-  memset (current_sound, 0, sizeof (struct sound));
+  current_sound_device = xzalloc (sizeof (struct sound_device));
+  current_sound = xzalloc (sizeof (struct sound));
   record_unwind_protect (sound_cleanup, Qnil);
   current_sound->header = (char *) alloca (MAX_SOUND_HEADER_BYTES);
 

=== modified file 'src/sysdep.c'
--- a/src/sysdep.c      2012-06-30 15:32:51 +0000
+++ b/src/sysdep.c      2012-07-05 06:32:41 +0000
@@ -851,7 +851,7 @@
     return;                     /* The tty is suspended. */
 
   if (! tty_out->old_tty)
-    tty_out->old_tty = (struct emacs_tty *) xmalloc (sizeof (struct 
emacs_tty));
+    tty_out->old_tty = xmalloc (sizeof (struct emacs_tty));
 
   emacs_get_tty (fileno (tty_out->input), tty_out->old_tty);
 

=== modified file 'src/term.c'
--- a/src/term.c        2012-06-28 07:50:27 +0000
+++ b/src/term.c        2012-07-05 06:32:41 +0000
@@ -2863,8 +2863,7 @@
   if (! FRAME_TERMCAP_P (f))
     abort ();
 
-  t = xmalloc (sizeof (struct tty_output));
-  memset (t, 0, sizeof (struct tty_output));
+  t = xzalloc (sizeof (struct tty_output));
 
   t->display_info = FRAME_TERMINAL (f)->display_info.tty;
 
@@ -3065,9 +3064,8 @@
   been_here = 1;
   tty = &the_only_display_info;
 #else
-  tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info));
+  tty = xzalloc (sizeof (struct tty_display_info));
 #endif
-  memset (tty, 0, sizeof (struct tty_display_info));
   tty->next = tty_list;
   tty_list = tty;
 
@@ -3075,7 +3073,7 @@
   terminal->display_info.tty = tty;
   tty->terminal = terminal;
 
-  tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm));
+  tty->Wcm = xmalloc (sizeof (struct cm));
   Wcm_clear (tty);
 
   encode_terminal_src_size = 0;
@@ -3136,7 +3134,7 @@
 
   Wcm_clear (tty);
 
-  tty->termcap_term_buffer = (char *) xmalloc (buffer_size);
+  tty->termcap_term_buffer = xmalloc (buffer_size);
 
   /* On some systems, tgetent tries to access the controlling
      terminal. */
@@ -3177,7 +3175,7 @@
     abort ();
   buffer_size = strlen (tty->termcap_term_buffer);
 #endif
-  tty->termcap_strings_buffer = area = (char *) xmalloc (buffer_size);
+  tty->termcap_strings_buffer = area = xmalloc (buffer_size);
   tty->TS_ins_line = tgetstr ("al", address);
   tty->TS_ins_multi_lines = tgetstr ("AL", address);
   tty->TS_bell = tgetstr ("bl", address);
@@ -3345,7 +3343,7 @@
   tty->mouse_highlight.mouse_face_window = Qnil;
 #endif
 
-  terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+  terminal->kboard = xmalloc (sizeof (KBOARD));
   init_kboard (terminal->kboard);
   KVAR (terminal->kboard, Vwindow_system) = Qnil;
   terminal->kboard->next_kboard = all_kboards;

=== modified file 'src/termcap.c'
--- a/src/termcap.c     2012-05-21 15:36:54 +0000
+++ b/src/termcap.c     2012-07-05 06:32:41 +0000
@@ -153,7 +153,7 @@
       p = ptr;
       while ((c = *p++) && c != ':' && c != '\n')
        ;
-      ret = (char *) xmalloc (p - ptr + 1);
+      ret = xmalloc (p - ptr + 1);
     }
   else
     ret = *area;
@@ -377,7 +377,7 @@
       if (!bp)
        {
          malloc_size = 1 + strlen (term);
-         bp = (char *) xmalloc (malloc_size);
+         bp = xmalloc (malloc_size);
        }
       strcpy (bp, term);
       goto ret;
@@ -440,13 +440,13 @@
 
   buf.size = BUFSIZE;
   /* Add 1 to size to ensure room for terminating null.  */
-  buf.beg = (char *) xmalloc (buf.size + 1);
+  buf.beg = xmalloc (buf.size + 1);
   term = indirect ? indirect : (char *)name;
 
   if (!bp)
     {
       malloc_size = indirect ? strlen (tcenv) + 1 : buf.size;
-      bp = (char *) xmalloc (malloc_size);
+      bp = xmalloc (malloc_size);
     }
   tc_search_point = bp1 = bp;
 

=== modified file 'src/terminal.c'
--- a/src/terminal.c    2012-06-26 14:41:01 +0000
+++ b/src/terminal.c    2012-07-05 06:32:41 +0000
@@ -230,10 +230,8 @@
 
   terminal->id = next_terminal_id++;
 
-  terminal->keyboard_coding =
-    (struct coding_system *) xmalloc (sizeof (struct coding_system));
-  terminal->terminal_coding =
-    (struct coding_system *) xmalloc (sizeof (struct coding_system));
+  terminal->keyboard_coding = xmalloc (sizeof (struct coding_system));
+  terminal->terminal_coding = xmalloc (sizeof (struct coding_system));
 
   /* If default coding systems for the terminal and the keyboard are
      already defined, use them in preference to the defaults.  This is

=== modified file 'src/tparam.c'
--- a/src/tparam.c      2012-05-21 15:36:54 +0000
+++ b/src/tparam.c      2012-07-05 06:32:41 +0000
@@ -98,7 +98,7 @@
          if (outlen == 0)
            {
              outlen = len + 40;
-             new = (char *) xmalloc (outlen);
+             new = xmalloc (outlen);
              memcpy (new, outstring, offset);
            }
          else

=== modified file 'src/w16select.c'
--- a/src/w16select.c   2012-06-16 12:24:15 +0000
+++ b/src/w16select.c   2012-07-05 06:32:41 +0000
@@ -493,7 +493,7 @@
 
       setup_coding_system (Fcheck_coding_system (coding_system), &coding);
       coding.dst_bytes = nbytes * 4;
-      coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
+      coding.destination = xmalloc (coding.dst_bytes);
       Vnext_selection_coding_system = Qnil;
       coding.mode |= CODING_MODE_LAST_BLOCK;
       dst = coding.destination;
@@ -572,7 +572,7 @@
     goto unblock;
 
   if ((data_size = get_clipboard_data_size (CF_OEMTEXT)) == 0 ||
-      (htext = (unsigned char *)xmalloc (data_size)) == 0)
+      (htext = xmalloc (data_size)) == 0)
     goto closeclip;
 
   /* need to know final size after '\r' chars are removed because

=== modified file 'src/w32.c'
--- a/src/w32.c 2012-06-30 15:55:27 +0000
+++ b/src/w32.c 2012-07-05 06:32:41 +0000
@@ -1476,7 +1476,7 @@
       lpvalue = NULL;
 
       if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == 
ERROR_SUCCESS
-         && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL
+         && (lpvalue = xmalloc (cbData)) != NULL
          && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) 
== ERROR_SUCCESS)
        {
           RegCloseKey (hrootkey);
@@ -1493,7 +1493,7 @@
       lpvalue = NULL;
 
       if (RegQueryValueEx (hrootkey, key, NULL, NULL, NULL, &cbData) == 
ERROR_SUCCESS
-         && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL
+         && (lpvalue = xmalloc (cbData)) != NULL
          && RegQueryValueEx (hrootkey, key, NULL, lpdwtype, lpvalue, &cbData) 
== ERROR_SUCCESS)
        {
           RegCloseKey (hrootkey);
@@ -2169,7 +2169,7 @@
         entry if present.  */
       if (info == NULL)
        {
-         info = (volume_info_data *) xmalloc (sizeof (volume_info_data));
+         info = xmalloc (sizeof (volume_info_data));
          add_volume_info (root_dir, info);
        }
       else

=== modified file 'src/w32fns.c'
--- a/src/w32fns.c      2012-06-28 19:09:41 +0000
+++ b/src/w32fns.c      2012-07-05 06:32:41 +0000
@@ -1006,8 +1006,7 @@
     }
 
   /* not already mapped, so add to list and recreate Windows palette */
-  list = (struct w32_palette_entry *)
-    xmalloc (sizeof (struct w32_palette_entry));
+  list = xmalloc (sizeof (struct w32_palette_entry));
   SET_W32_COLOR (list->entry, color);
   list->refcount = 1;
   list->next = FRAME_W32_DISPLAY_INFO (f)->color_list;
@@ -1109,8 +1108,7 @@
          if (entry == NULL && alloc)
            {
              /* not already mapped, so add to list */
-             entry = (struct w32_palette_entry *)
-               xmalloc (sizeof (struct w32_palette_entry));
+             entry = xmalloc (sizeof (struct w32_palette_entry));
              SET_W32_COLOR (entry->entry, XUINT (tem));
              entry->next = NULL;
              *prev = entry;
@@ -3881,7 +3879,7 @@
 
   {
     char *str = SSDATA (Vx_resource_name);
-    f->namebuf = (char *) xmalloc (strlen (str) + 1);
+    f->namebuf = xmalloc (strlen (str) + 1);
     strcpy (f->namebuf, str);
   }
 
@@ -4145,9 +4143,7 @@
   f->terminal = dpyinfo->terminal;
 
   f->output_method = output_w32;
-  f->output_data.w32 =
-    (struct w32_output *) xmalloc (sizeof (struct w32_output));
-  memset (f->output_data.w32, 0, sizeof (struct w32_output));
+  f->output_data.w32 = xzalloc (sizeof (struct w32_output));
   FRAME_FONTSET (f) = -1;
 
   f->icon_name
@@ -5230,9 +5226,7 @@
      counts etc.  */
   f->terminal = dpyinfo->terminal;
   f->output_method = output_w32;
-  f->output_data.w32 =
-    (struct w32_output *) xmalloc (sizeof (struct w32_output));
-  memset (f->output_data.w32, 0, sizeof (struct w32_output));
+  f->output_data.w32 = xzalloc (sizeof (struct w32_output));
 
   FRAME_FONTSET (f)  = -1;
   f->icon_name = Qnil;
@@ -6687,7 +6681,7 @@
       return Qnil;
     }
   /* Allocate memory for the PRINTER_INFO_2 struct */
-  ppi2 = (PRINTER_INFO_2 *) xmalloc (dwNeeded);
+  ppi2 = xmalloc (dwNeeded);
   if (!ppi2)
     {
       ClosePrinter (hPrn);

=== modified file 'src/w32font.c'
--- a/src/w32font.c     2012-05-02 10:12:13 +0000
+++ b/src/w32font.c     2012-07-05 06:32:41 +0000
@@ -529,9 +529,7 @@
          if (!w32_font->cached_metrics[block])
            {
              w32_font->cached_metrics[block]
-               = xmalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
-             memset (w32_font->cached_metrics[block], 0,
-                     CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
+               = xzalloc (CACHE_BLOCKSIZE * sizeof (struct w32_metric_cache));
            }
 
          char_metric = w32_font->cached_metrics[block] + pos_in_block;

=== modified file 'src/w32reg.c'
--- a/src/w32reg.c      2012-01-19 07:21:25 +0000
+++ b/src/w32reg.c      2012-07-05 06:32:41 +0000
@@ -110,7 +110,7 @@
        }
 
       ok = (keyname
-           && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL
+           && (lpvalue = xmalloc (cbData)) != NULL
            && RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, 
&cbData) == ERROR_SUCCESS);
 
       RegCloseKey (hrootkey);

=== modified file 'src/w32select.c'
--- a/src/w32select.c   2012-02-11 09:50:27 +0000
+++ b/src/w32select.c   2012-07-05 06:32:41 +0000
@@ -216,7 +216,7 @@
 
   setup_windows_coding_system (coding_system, &coding);
   coding.dst_bytes = SBYTES (current_text) * 2;
-  coding.destination = (unsigned char *) xmalloc (coding.dst_bytes);
+  coding.destination = xmalloc (coding.dst_bytes);
   encode_coding_object (&coding, current_text, 0, 0,
                        SCHARS (current_text), SBYTES (current_text), Qnil);
 

=== modified file 'src/w32term.c'
--- a/src/w32term.c     2012-06-28 07:50:50 +0000
+++ b/src/w32term.c     2012-07-05 06:32:41 +0000
@@ -285,8 +285,7 @@
 XGCValues *
 XCreateGC (void *ignore, Window window, unsigned long mask, XGCValues *xgcv)
 {
-  XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues));
-  memset (gc, 0, sizeof (XGCValues));
+  XGCValues *gc = xzalloc (sizeof (XGCValues));
 
   XChangeGC (ignore, gc, mask, xgcv);
 
@@ -6060,10 +6059,8 @@
                                  w32_display_name_list);
   dpyinfo->name_list_element = XCAR (w32_display_name_list);
 
-  dpyinfo->w32_id_name
-    = (char *) xmalloc (SCHARS (Vinvocation_name)
-                       + SCHARS (Vsystem_name)
-                       + 2);
+  dpyinfo->w32_id_name = xmalloc (SCHARS (Vinvocation_name)
+                                 + SCHARS (Vsystem_name) + 2);
   sprintf (dpyinfo->w32_id_name, "address@hidden",
           SDATA (Vinvocation_name), SDATA (Vsystem_name));
 
@@ -6228,7 +6225,7 @@
   /* We don't yet support separate terminals on W32, so don't try to share
      keyboards between virtual terminals that are on the same physical
      terminal like X does.  */
-  terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+  terminal->kboard = xmalloc (sizeof (KBOARD));
   init_kboard (terminal->kboard);
   KVAR (terminal->kboard, Vwindow_system) = intern ("w32");
   terminal->kboard->next_kboard = all_kboards;
@@ -6280,7 +6277,7 @@
   terminal = w32_create_terminal (dpyinfo);
 
   /* Set the name of the terminal. */
-  terminal->name = (char *) xmalloc (SBYTES (display_name) + 1);
+  terminal->name = xmalloc (SBYTES (display_name) + 1);
   strncpy (terminal->name, SDATA (display_name), SBYTES (display_name));
   terminal->name[SBYTES (display_name)] = 0;
 

=== modified file 'src/w32uniscribe.c'
--- a/src/w32uniscribe.c        2012-01-19 07:21:25 +0000
+++ b/src/w32uniscribe.c        2012-07-05 06:32:41 +0000
@@ -231,7 +231,7 @@
   /* First we need to break up the glyph string into runs of glyphs that
      can be treated together.  First try a single run.  */
   max_items = 2;
-  items = (SCRIPT_ITEM *) xmalloc (sizeof (SCRIPT_ITEM) * max_items + 1);
+  items = xmalloc (sizeof (SCRIPT_ITEM) * max_items + 1);
 
   while ((result = ScriptItemize (chars, nchars, max_items, NULL, NULL,
                                  items, &nitems)) == E_OUTOFMEMORY)

=== modified file 'src/widget.c'
--- a/src/widget.c      2012-01-19 07:21:25 +0000
+++ b/src/widget.c      2012-07-05 06:32:41 +0000
@@ -435,7 +435,7 @@
                 flags & XNegative ? '-' : '+', x < 0 ? -x : x,
                 flags & YNegative ? '-' : '+', y < 0 ? -y : y);
        len = strlen (shell_position) + 1;
-       tem = (char *) xmalloc (len);
+       tem = xmalloc (len);
        strncpy (tem, shell_position, len);
        XtVaSetValues (wmshell, XtNgeometry, tem, NULL);
       }
@@ -445,7 +445,7 @@
        char *tem;
        sprintf (shell_position, "=%dx%d", pixel_width, pixel_height);
        len = strlen (shell_position) + 1;
-       tem = (char *) xmalloc (len);
+       tem = xmalloc (len);
        strncpy (tem, shell_position, len);
        XtVaSetValues (wmshell, XtNgeometry, tem, NULL);
       }

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2012-06-29 18:52:54 +0000
+++ b/src/xdisp.c       2012-07-05 06:32:41 +0000
@@ -29055,7 +29055,7 @@
     /* Allocate the buffer for frame titles.
        Also used for `format-mode-line'.  */
     int size = 100;
-    mode_line_noprop_buf = (char *) xmalloc (size);
+    mode_line_noprop_buf = xmalloc (size);
     mode_line_noprop_buf_end = mode_line_noprop_buf + size;
     mode_line_noprop_ptr = mode_line_noprop_buf;
     mode_line_target = MODE_LINE_DISPLAY;

=== modified file 'src/xfaces.c'
--- a/src/xfaces.c      2012-06-28 07:50:50 +0000
+++ b/src/xfaces.c      2012-07-05 06:32:41 +0000
@@ -4148,8 +4148,7 @@
 static struct face *
 make_realized_face (Lisp_Object *attr)
 {
-  struct face *face = (struct face *) xmalloc (sizeof *face);
-  memset (face, 0, sizeof *face);
+  struct face *face = xzalloc (sizeof *face);
   face->ascii_face = face;
   memcpy (face->lface, attr, sizeof face->lface);
   return face;
@@ -4294,13 +4293,11 @@
   struct face_cache *c;
   int size;
 
-  c = (struct face_cache *) xmalloc (sizeof *c);
-  memset (c, 0, sizeof *c);
+  c = xzalloc (sizeof *c);
   size = FACE_CACHE_BUCKETS_SIZE * sizeof *c->buckets;
-  c->buckets = (struct face **) xmalloc (size);
-  memset (c->buckets, 0, size);
+  c->buckets = xzalloc (size);
   c->size = 50;
-  c->faces_by_id = (struct face **) xmalloc (c->size * sizeof *c->faces_by_id);
+  c->faces_by_id = xmalloc (c->size * sizeof *c->faces_by_id);
   c->f = f;
   c->menu_face_changed_p = menu_face_changed_default;
   return c;
@@ -5582,7 +5579,7 @@
   struct face_cache *cache = FRAME_FACE_CACHE (f);
   struct face *face;
 
-  face = (struct face *) xmalloc (sizeof *face);
+  face = xmalloc (sizeof *face);
   *face = *base_face;
   face->gc = 0;
   face->extra = NULL;

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2012-06-28 07:50:50 +0000
+++ b/src/xfns.c        2012-07-05 06:32:41 +0000
@@ -2368,7 +2368,7 @@
 
   {
     char *str = SSDATA (Vx_resource_name);
-    f->namebuf = (char *) xmalloc (strlen (str) + 1);
+    f->namebuf = xmalloc (strlen (str) + 1);
     strcpy (f->namebuf, str);
   }
 
@@ -3129,8 +3129,7 @@
   f->terminal = dpyinfo->terminal;
 
   f->output_method = output_x_window;
-  f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
-  memset (f->output_data.x, 0, sizeof (struct x_output));
+  f->output_data.x = xzalloc (sizeof (struct x_output));
   f->output_data.x->icon_bitmap = -1;
   FRAME_FONTSET (f) = -1;
   f->output_data.x->scroll_bar_foreground_pixel = -1;
@@ -4615,8 +4614,7 @@
      from this point on, x_destroy_window might screw up reference
      counts etc.  */
   f->output_method = output_x_window;
-  f->output_data.x = (struct x_output *) xmalloc (sizeof (struct x_output));
-  memset (f->output_data.x, 0, sizeof (struct x_output));
+  f->output_data.x = xzalloc (sizeof (struct x_output));
   f->output_data.x->icon_bitmap = -1;
   FRAME_FONTSET (f) = -1;
   f->output_data.x->scroll_bar_foreground_pixel = -1;

=== modified file 'src/xmenu.c'
--- a/src/xmenu.c       2012-06-25 04:05:48 +0000
+++ b/src/xmenu.c       2012-07-05 06:32:41 +0000
@@ -961,7 +961,7 @@
   else if (!f->output_data.x->saved_menu_event && !deep_p)
     {
       deep_p = 1;
-      f->output_data.x->saved_menu_event = (XEvent*)xmalloc (sizeof (XEvent));
+      f->output_data.x->saved_menu_event = xmalloc (sizeof (XEvent));
       f->output_data.x->saved_menu_event->type = 0;
     }
 

=== modified file 'src/xrdb.c'
--- a/src/xrdb.c        2012-02-10 18:58:48 +0000
+++ b/src/xrdb.c        2012-07-05 06:32:41 +0000
@@ -87,7 +87,7 @@
 
   if (result)
     {
-      char *copy = (char *) xmalloc (strlen (result) + 1);
+      char *copy = xmalloc (strlen (result) + 1);
       strcpy (copy, result);
       return copy;
     }
@@ -132,7 +132,7 @@
   char *lang = getenv ("LANG");
 
   ptrdiff_t path_size = 100;
-  char *path = (char *) xmalloc (path_size);
+  char *path = xmalloc (path_size);
   ptrdiff_t path_len = 0;
 
   const char *p = string;
@@ -258,7 +258,7 @@
   if (ptr == NULL)
     return xstrdup ("/");
 
-  copy = (char *) xmalloc (strlen (ptr) + 2);
+  copy = xmalloc (strlen (ptr) + 2);
   strcpy (copy, ptr);
   strcat (copy, "/");
 
@@ -400,7 +400,7 @@
       char *xdefault;
 
       home = gethomedir ();
-      xdefault = (char *) xmalloc (strlen (home) + sizeof (".Xdefaults"));
+      xdefault = xmalloc (strlen (home) + sizeof (".Xdefaults"));
       strcpy (xdefault, home);
       strcat (xdefault, ".Xdefaults");
       db = XrmGetFileDatabase (xdefault);

=== modified file 'src/xselect.c'
--- a/src/xselect.c     2012-06-28 07:50:27 +0000
+++ b/src/xselect.c     2012-07-05 06:32:41 +0000
@@ -180,16 +180,11 @@
        }
     }
 
-  queue_tmp
-    = (struct selection_event_queue *) xmalloc (sizeof (struct 
selection_event_queue));
-
-  if (queue_tmp != NULL)
-    {
-      TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp);
-      queue_tmp->event = *event;
-      queue_tmp->next = selection_queue;
-      selection_queue = queue_tmp;
-    }
+  queue_tmp = xmalloc (sizeof (struct selection_event_queue));
+  TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp);
+  queue_tmp->event = *event;
+  queue_tmp->next = selection_queue;
+  selection_queue = queue_tmp;
 }
 
 /* Start queuing SELECTION_REQUEST_EVENT events.  */
@@ -1085,7 +1080,7 @@
 expect_property_change (Display *display, Window window,
                         Atom property, int state)
 {
-  struct prop_location *pl = (struct prop_location *) xmalloc (sizeof *pl);
+  struct prop_location *pl = xmalloc (sizeof *pl);
   pl->identifier = ++prop_location_identifier;
   pl->display = display;
   pl->window = window;
@@ -1446,7 +1441,7 @@
   struct prop_location *wait_object;
   if (min (PTRDIFF_MAX, SIZE_MAX) < min_size_bytes)
     memory_full (SIZE_MAX);
-  *data_ret = (unsigned char *) xmalloc (min_size_bytes);
+  *data_ret = xmalloc (min_size_bytes);
   *size_bytes_ret = min_size_bytes;
 
   TRACE1 ("Read %u bytes incrementally", min_size_bytes);
@@ -1780,7 +1775,7 @@
     }
   else if (SYMBOLP (obj))
     {
-      *data_ret = (unsigned char *) xmalloc (sizeof (Atom) + 1);
+      *data_ret = xmalloc (sizeof (Atom) + 1);
       *format_ret = 32;
       *size_ret = 1;
       (*data_ret) [sizeof (Atom)] = 0;
@@ -1789,7 +1784,7 @@
     }
   else if (RANGED_INTEGERP (X_SHRT_MIN, obj, X_SHRT_MAX))
     {
-      *data_ret = (unsigned char *) xmalloc (sizeof (short) + 1);
+      *data_ret = xmalloc (sizeof (short) + 1);
       *format_ret = 16;
       *size_ret = 1;
       (*data_ret) [sizeof (short)] = 0;
@@ -1802,7 +1797,7 @@
                   || (CONSP (XCDR (obj))
                       && INTEGERP (XCAR (XCDR (obj)))))))
     {
-      *data_ret = (unsigned char *) xmalloc (sizeof (unsigned long) + 1);
+      *data_ret = xmalloc (sizeof (unsigned long) + 1);
       *format_ret = 32;
       *size_ret = 1;
       (*data_ret) [sizeof (unsigned long)] = 0;

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2012-06-28 07:50:50 +0000
+++ b/src/xterm.c       2012-07-05 06:32:41 +0000
@@ -5777,9 +5777,9 @@
      do                                                                        
\
        {                                                               \
         if (f->output_data.x->saved_menu_event == 0)                   \
-           f->output_data.x->saved_menu_event                          \
-            = (XEvent *) xmalloc (sizeof (XEvent));                    \
-         *f->output_data.x->saved_menu_event = event;                   \
+           f->output_data.x->saved_menu_event =                                
\
+            xmalloc (sizeof (XEvent));                                 \
+         *f->output_data.x->saved_menu_event = event;                  \
         inev.ie.kind = MENU_BAR_ACTIVATE_EVENT;                        \
         XSETFRAME (inev.ie.frame_or_window, f);                        \
        }                                                               \
@@ -8190,11 +8190,11 @@
       struct xim_inst_t *xim_inst;
       ptrdiff_t len;
 
-      xim_inst = (struct xim_inst_t *) xmalloc (sizeof (struct xim_inst_t));
+      xim_inst = xmalloc (sizeof (struct xim_inst_t));
       dpyinfo->xim_callback_data = xim_inst;
       xim_inst->dpyinfo = dpyinfo;
       len = strlen (resource_name);
-      xim_inst->resource_name = (char *) xmalloc (len + 1);
+      xim_inst->resource_name = xmalloc (len + 1);
       memcpy (xim_inst->resource_name, resource_name, len + 1);
       XRegisterIMInstantiateCallback (dpyinfo->display, dpyinfo->xrdb,
                                      resource_name, emacs_class,
@@ -10098,8 +10098,7 @@
 
   /* We have definitely succeeded.  Record the new connection.  */
 
-  dpyinfo = (struct x_display_info *) xmalloc (sizeof (struct x_display_info));
-  memset (dpyinfo, 0, sizeof *dpyinfo);
+  dpyinfo = xzalloc (sizeof (struct x_display_info));
   hlinfo = &dpyinfo->mouse_highlight;
 
   terminal = x_create_terminal (dpyinfo);
@@ -10117,7 +10116,7 @@
       terminal->kboard = share->terminal->kboard;
     else
       {
-       terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+       terminal->kboard = xmalloc (sizeof (KBOARD));
        init_kboard (terminal->kboard);
        KVAR (terminal->kboard, Vwindow_system) = Qx;
 
@@ -10171,7 +10170,7 @@
   dpyinfo->display = dpy;
 
   /* Set the name of the terminal. */
-  terminal->name = (char *) xmalloc (SBYTES (display_name) + 1);
+  terminal->name = xmalloc (SBYTES (display_name) + 1);
   memcpy (terminal->name, SSDATA (display_name), SBYTES (display_name));
   terminal->name[SBYTES (display_name)] = 0;
 
@@ -10182,10 +10181,8 @@
   lim = min (PTRDIFF_MAX, SIZE_MAX) - sizeof "@";
   if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name))
     memory_full (SIZE_MAX);
-  dpyinfo->x_id_name
-    = (char *) xmalloc (SBYTES (Vinvocation_name)
-                       + SBYTES (Vsystem_name)
-                       + 2);
+  dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name)
+                               + SBYTES (Vsystem_name) + 2);
   strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"),
          SSDATA (Vsystem_name));
 


reply via email to

[Prev in Thread] Current Thread [Next in Thread]