emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r108885: More xmalloc and related cle


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108885: More xmalloc and related cleanup.
Date: Thu, 05 Jul 2012 11:35:48 -0700
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108885
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Thu 2012-07-05 11:35:48 -0700
message:
  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.
modified:
  src/ChangeLog
  src/alloc.c
  src/bidi.c
  src/buffer.c
  src/buffer.h
  src/bytecode.c
  src/callint.c
  src/callproc.c
  src/charset.c
  src/coding.c
  src/composite.c
  src/data.c
  src/dispnew.c
  src/doc.c
  src/editfns.c
  src/emacs.c
  src/eval.c
  src/fileio.c
  src/filelock.c
  src/fns.c
  src/font.c
  src/fontset.c
  src/frame.c
  src/fringe.c
  src/ftfont.c
  src/ftxfont.c
  src/gmalloc.c
  src/gtkutil.c
  src/image.c
  src/keyboard.c
  src/keymap.c
  src/lread.c
  src/macros.c
  src/menu.c
  src/nsfns.m
  src/nsfont.m
  src/nsmenu.m
  src/nsterm.m
  src/print.c
  src/process.c
  src/ralloc.c
  src/regex.c
  src/region-cache.c
  src/scroll.c
  src/search.c
  src/sound.c
  src/syntax.c
  src/sysdep.c
  src/term.c
  src/termcap.c
  src/unexmacosx.c
  src/window.c
  src/xdisp.c
  src/xfaces.c
  src/xfns.c
  src/xftfont.c
  src/xgselect.c
  src/xmenu.c
  src/xrdb.c
  src/xselect.c
  src/xterm.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-07-05 16:28:34 +0000
+++ b/src/ChangeLog     2012-07-05 18:35:48 +0000
@@ -1,3 +1,28 @@
+2012-07-05  Paul Eggert  <address@hidden>
+
+       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.
+
 2012-07-05  Eli Zaretskii  <address@hidden>
 
        * xdisp.c (display_line): Fix horizontal pixel coordinates when

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2012-07-05 06:32:41 +0000
+++ b/src/alloc.c       2012-07-05 18:35:48 +0000
@@ -615,7 +615,7 @@
   if (SIZE_MAX - overhead < size)
     abort ();
 
-  val = (unsigned char *) malloc (size + overhead);
+  val = malloc (size + overhead);
   if (val && check_depth == 1)
     {
       memcpy (val, xmalloc_overrun_check_header, XMALLOC_OVERRUN_CHECK_SIZE);
@@ -923,7 +923,7 @@
   allocated_mem_type = type;
 #endif
 
-  val = (void *) malloc (nbytes);
+  val = malloc (nbytes);
 
 #if ! USE_LSB_TAG
   /* If the memory just allocated cannot be addressed thru a Lisp
@@ -1309,7 +1309,7 @@
     __malloc_extra_blocks = malloc_hysteresis;
 #endif
 
-  value = (void *) malloc (size);
+  value = malloc (size);
 
 #ifdef GC_MALLOC_CHECK
   {
@@ -1371,7 +1371,7 @@
   dont_register_blocks = 1;
 #endif /* GC_MALLOC_CHECK */
 
-  value = (void *) realloc (ptr, size);
+  value = realloc (ptr, size);
 
 #ifdef GC_MALLOC_CHECK
   dont_register_blocks = 0;
@@ -1523,10 +1523,8 @@
     {
       if (interval_block_index == INTERVAL_BLOCK_SIZE)
        {
-         register struct interval_block *newi;
-
-         newi = (struct interval_block *) lisp_malloc (sizeof *newi,
-                                                       MEM_TYPE_NON_LISP);
+         struct interval_block *newi
+           = lisp_malloc (sizeof *newi, MEM_TYPE_NON_LISP);
 
          newi->next = interval_block;
          interval_block = newi;
@@ -1932,10 +1930,9 @@
      add all the Lisp_Strings in it to the free-list.  */
   if (string_free_list == NULL)
     {
-      struct string_block *b;
+      struct string_block *b = lisp_malloc (sizeof *b, MEM_TYPE_STRING);
       int i;
 
-      b = (struct string_block *) lisp_malloc (sizeof *b, MEM_TYPE_STRING);
       b->next = string_blocks;
       string_blocks = b;
 
@@ -2021,7 +2018,7 @@
       mallopt (M_MMAP_MAX, 0);
 #endif
 
-      b = (struct sblock *) lisp_malloc (size + GC_STRING_EXTRA, 
MEM_TYPE_NON_LISP);
+      b = lisp_malloc (size + GC_STRING_EXTRA, MEM_TYPE_NON_LISP);
 
 #ifdef DOUG_LEA_MALLOC
       /* Back to a reasonable maximum of mmap'ed areas. */
@@ -2039,7 +2036,7 @@
               < (needed + GC_STRING_EXTRA)))
     {
       /* Not enough room in the current sblock.  */
-      b = (struct sblock *) lisp_malloc (SBLOCK_SIZE, MEM_TYPE_NON_LISP);
+      b = lisp_malloc (SBLOCK_SIZE, MEM_TYPE_NON_LISP);
       b->next_free = &b->first_data;
       b->first_data.string = NULL;
       b->next = NULL;
@@ -2619,10 +2616,8 @@
     {
       if (float_block_index == FLOAT_BLOCK_SIZE)
        {
-         register struct float_block *new;
-
-         new = (struct float_block *) lisp_align_malloc (sizeof *new,
-                                                         MEM_TYPE_FLOAT);
+         struct float_block *new
+           = lisp_align_malloc (sizeof *new, MEM_TYPE_FLOAT);
          new->next = float_block;
          memset (new->gcmarkbits, 0, sizeof new->gcmarkbits);
          float_block = new;
@@ -2738,9 +2733,8 @@
     {
       if (cons_block_index == CONS_BLOCK_SIZE)
        {
-         register struct cons_block *new;
-         new = (struct cons_block *) lisp_align_malloc (sizeof *new,
-                                                        MEM_TYPE_CONS);
+         struct cons_block *new
+           = lisp_align_malloc (sizeof *new, MEM_TYPE_CONS);
          memset (new->gcmarkbits, 0, sizeof new->gcmarkbits);
          new->next = cons_block;
          cons_block = new;
@@ -2972,7 +2966,7 @@
 static struct vector_block *
 allocate_vector_block (void)
 {
-  struct vector_block *block = xmalloc (sizeof (struct vector_block));
+  struct vector_block *block = xmalloc (sizeof *block);
 
 #if GC_MARK_STACK && !defined GC_MALLOC_CHECK
   mem_insert (block->data, block->data + VECTOR_BLOCK_BYTES,
@@ -3198,7 +3192,7 @@
        p = allocate_vector_from_block (vroundup (nbytes));
       else
        {
-         p = (struct Lisp_Vector *) lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE);
+         p = lisp_malloc (nbytes, MEM_TYPE_VECTORLIKE);
          p->header.next.vector = large_vectors;
          large_vectors = p;
        }
@@ -3253,7 +3247,7 @@
 struct buffer *
 allocate_buffer (void)
 {
-  struct buffer *b = lisp_malloc (sizeof (struct buffer), MEM_TYPE_BUFFER);
+  struct buffer *b = lisp_malloc (sizeof *b, MEM_TYPE_BUFFER);
 
   XSETPVECTYPESIZE (b, PVEC_BUFFER, (offsetof (struct buffer, own_text)
                                     - header_size) / word_size);
@@ -3487,9 +3481,8 @@
     {
       if (symbol_block_index == SYMBOL_BLOCK_SIZE)
        {
-         struct symbol_block *new;
-         new = (struct symbol_block *) lisp_malloc (sizeof *new,
-                                                    MEM_TYPE_SYMBOL);
+         struct symbol_block *new
+           = lisp_malloc (sizeof *new, MEM_TYPE_SYMBOL);
          new->next = symbol_block;
          symbol_block = new;
          symbol_block_index = 0;
@@ -3580,9 +3573,7 @@
     {
       if (marker_block_index == MARKER_BLOCK_SIZE)
        {
-         struct marker_block *new;
-         new = (struct marker_block *) lisp_malloc (sizeof *new,
-                                                    MEM_TYPE_MISC);
+         struct marker_block *new = lisp_malloc (sizeof *new, MEM_TYPE_MISC);
          new->next = marker_block;
          marker_block = new;
          marker_block_index = 0;
@@ -3775,25 +3766,25 @@
 {
 #ifndef SYSTEM_MALLOC
   if (spare_memory[0] == 0)
-    spare_memory[0] = (char *) malloc (SPARE_MEMORY);
+    spare_memory[0] = malloc (SPARE_MEMORY);
   if (spare_memory[1] == 0)
-    spare_memory[1] = (char *) lisp_align_malloc (sizeof (struct cons_block),
+    spare_memory[1] = lisp_align_malloc (sizeof (struct cons_block),
                                                  MEM_TYPE_CONS);
   if (spare_memory[2] == 0)
-    spare_memory[2] = (char *) lisp_align_malloc (sizeof (struct cons_block),
-                                                 MEM_TYPE_CONS);
+    spare_memory[2] = lisp_align_malloc (sizeof (struct cons_block),
+                                        MEM_TYPE_CONS);
   if (spare_memory[3] == 0)
-    spare_memory[3] = (char *) lisp_align_malloc (sizeof (struct cons_block),
-                                                 MEM_TYPE_CONS);
+    spare_memory[3] = lisp_align_malloc (sizeof (struct cons_block),
+                                        MEM_TYPE_CONS);
   if (spare_memory[4] == 0)
-    spare_memory[4] = (char *) lisp_align_malloc (sizeof (struct cons_block),
-                                                 MEM_TYPE_CONS);
+    spare_memory[4] = lisp_align_malloc (sizeof (struct cons_block),
+                                        MEM_TYPE_CONS);
   if (spare_memory[5] == 0)
-    spare_memory[5] = (char *) lisp_malloc (sizeof (struct string_block),
-                                           MEM_TYPE_STRING);
+    spare_memory[5] = lisp_malloc (sizeof (struct string_block),
+                                  MEM_TYPE_STRING);
   if (spare_memory[6] == 0)
-    spare_memory[6] = (char *) lisp_malloc (sizeof (struct string_block),
-                                           MEM_TYPE_STRING);
+    spare_memory[6] = lisp_malloc (sizeof (struct string_block),
+                                  MEM_TYPE_STRING);
   if (spare_memory[0] && spare_memory[1] && spare_memory[5])
     Vmemory_full = Qnil;
 #endif
@@ -3893,7 +3884,7 @@
 
   /* Create a new node.  */
 #ifdef GC_MALLOC_CHECK
-  x = (struct mem_node *) _malloc_internal (sizeof *x);
+  x = _malloc_internal (sizeof *x);
   if (x == NULL)
     abort ();
 #else
@@ -5441,7 +5432,7 @@
        {
          if (stack_copy_size < stack_size)
            {
-             stack_copy = (char *) xrealloc (stack_copy, stack_size);
+             stack_copy = xrealloc (stack_copy, stack_size);
              stack_copy_size = stack_size;
            }
          memcpy (stack_copy, stack, stack_size);

=== modified file 'src/bidi.c'
--- a/src/bidi.c        2012-06-28 07:50:27 +0000
+++ b/src/bidi.c        2012-07-05 18:35:48 +0000
@@ -361,8 +361,7 @@
 {
   if (bidi_cache_size > BIDI_CACHE_CHUNK)
     {
-      bidi_cache
-       = (struct bidi_it *) xrealloc (bidi_cache, BIDI_CACHE_CHUNK * elsz);
+      bidi_cache = xrealloc (bidi_cache, BIDI_CACHE_CHUNK * elsz);
       bidi_cache_size = BIDI_CACHE_CHUNK;
     }
   bidi_cache_reset ();

=== modified file 'src/buffer.c'
--- a/src/buffer.c      2012-07-05 06:32:41 +0000
+++ b/src/buffer.c      2012-07-05 18:35:48 +0000
@@ -2793,11 +2793,11 @@
   Lisp_Object *v, tem;
 
   size = 10;
-  v = (Lisp_Object *) alloca (size * sizeof *v);
+  v = alloca (size * sizeof *v);
   n = overlays_in (start, end, 0, &v, &size, NULL, NULL);
   if (n > size)
     {
-      v = (Lisp_Object *) alloca (n * sizeof *v);
+      v = alloca (n * sizeof *v);
       overlays_in (start, end, 0, &v, &n, NULL, NULL);
     }
 
@@ -2885,8 +2885,7 @@
 sort_overlays (Lisp_Object *overlay_vec, ptrdiff_t noverlays, struct window *w)
 {
   ptrdiff_t i, j;
-  struct sortvec *sortvec;
-  sortvec = (struct sortvec *) alloca (noverlays * sizeof (struct sortvec));
+  struct sortvec *sortvec = alloca (noverlays * sizeof *sortvec);
 
   /* Put the valid and relevant overlays into sortvec.  */
 
@@ -3893,7 +3892,7 @@
 
   len = 10;
   /* We can't use alloca here because overlays_at can call xrealloc.  */
-  overlay_vec = xmalloc (len * sizeof (Lisp_Object));
+  overlay_vec = xmalloc (len * sizeof *overlay_vec);
 
   /* Put all the overlays we want in a vector in overlay_vec.
      Store the length in len.  */
@@ -3924,7 +3923,7 @@
   CHECK_NUMBER_COERCE_MARKER (end);
 
   len = 10;
-  overlay_vec = xmalloc (len * sizeof (Lisp_Object));
+  overlay_vec = xmalloc (len * sizeof *overlay_vec);
 
   /* Put all the overlays we want in a vector in overlay_vec.
      Store the length in len.  */
@@ -3952,7 +3951,7 @@
   CHECK_NUMBER_COERCE_MARKER (pos);
 
   len = 10;
-  overlay_vec = xmalloc (len * sizeof (Lisp_Object));
+  overlay_vec = xmalloc (len * sizeof *overlay_vec);
 
   /* Put all the overlays we want in a vector in overlay_vec.
      Store the length in len.
@@ -3996,7 +3995,7 @@
     return pos;
 
   len = 10;
-  overlay_vec = xmalloc (len * sizeof (Lisp_Object));
+  overlay_vec = xmalloc (len * sizeof *overlay_vec);
 
   /* Put all the overlays we want in a vector in overlay_vec.
      Store the length in len.
@@ -4251,7 +4250,7 @@
        First copy the vector contents, in case some of these hooks
        do subsequent modification of the buffer.  */
     ptrdiff_t size = last_overlay_modification_hooks_used;
-    Lisp_Object *copy = (Lisp_Object *) alloca (size * sizeof (Lisp_Object));
+    Lisp_Object *copy = alloca (size * sizeof *copy);
     ptrdiff_t i;
 
     memcpy (copy, XVECTOR (last_overlay_modification_hooks)->contents,
@@ -4873,7 +4872,7 @@
   /* If you add, remove, or reorder Lisp_Objects in a struct buffer, make
      sure that this is still correct.  Otherwise, mark_vectorlike may not
      trace all Lisp_Objects in buffer_defaults and buffer_local_symbols.  */
-  const int pvecsize 
+  const int pvecsize
     = (offsetof (struct buffer, own_text) - sizeof (struct vectorlike_header))
     / sizeof (Lisp_Object);
 
@@ -5089,7 +5088,7 @@
   if (!(IS_DIRECTORY_SEP (pwd[len - 1])))
     {
       /* Grow buffer to add directory separator and '\0'.  */
-      pwd = (char *) realloc (pwd, len + 2);
+      pwd = realloc (pwd, len + 2);
       if (!pwd)
        fatal ("`get_current_dir_name' failed: %s\n", strerror (errno));
       pwd[len] = DIRECTORY_SEP;

=== modified file 'src/buffer.h'
--- a/src/buffer.h      2012-07-03 18:24:42 +0000
+++ b/src/buffer.h      2012-07-05 18:35:48 +0000
@@ -918,13 +918,13 @@
 #define GET_OVERLAYS_AT(posn, overlays, noverlays, nextp, chrq)                
\
   do {                                                                 \
     ptrdiff_t maxlen = 40;                                             \
-    overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \
+    overlays = alloca (maxlen * sizeof *overlays);                     \
     noverlays = overlays_at (posn, 0, &overlays, &maxlen,              \
                             nextp, NULL, chrq);                        \
     if (noverlays > maxlen)                                            \
       {                                                                        
\
        maxlen = noverlays;                                             \
-       overlays = (Lisp_Object *) alloca (maxlen * sizeof (Lisp_Object)); \
+       overlays = alloca (maxlen * sizeof *overlays);                  \
        noverlays = overlays_at (posn, 0, &overlays, &maxlen,           \
                                 nextp, NULL, chrq);                    \
       }                                                                        
\

=== modified file 'src/bytecode.c'
--- a/src/bytecode.c    2012-06-19 16:56:28 +0000
+++ b/src/bytecode.c    2012-07-05 18:35:48 +0000
@@ -488,8 +488,7 @@
   stack.constants = vector;
   if (MAX_ALLOCA / sizeof (Lisp_Object) <= XFASTINT (maxdepth))
     memory_full (SIZE_MAX);
-  top = (Lisp_Object *) alloca ((XFASTINT (maxdepth) + 1)
-                                         * sizeof (Lisp_Object));
+  top = alloca ((XFASTINT (maxdepth) + 1) * sizeof *top);
 #if BYTE_MAINTAIN_TOP
   stack.bottom = top + 1;
   stack.top = NULL;

=== modified file 'src/callint.c'
--- a/src/callint.c     2012-06-16 12:24:15 +0000
+++ b/src/callint.c     2012-07-05 18:35:48 +0000
@@ -331,7 +331,7 @@
     {
       /* Make a copy of string so that if a GC relocates specs,
         `string' will still be valid.  */
-      string = (char *) alloca (SBYTES (specs) + 1);
+      string = alloca (SBYTES (specs) + 1);
       memcpy (string, SSDATA (specs), SBYTES (specs) + 1);
     }
   else
@@ -469,9 +469,9 @@
       < nargs)
     memory_full (SIZE_MAX);
 
-  args = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object));
-  visargs = (Lisp_Object *) alloca (nargs * sizeof (Lisp_Object));
-  varies = (signed char *) alloca (nargs);
+  args = alloca (nargs * sizeof *args);
+  visargs = alloca (nargs * sizeof *visargs);
+  varies = alloca (nargs * sizeof *varies);
 
   for (i = 0; i < nargs; i++)
     {

=== modified file 'src/callproc.c'
--- a/src/callproc.c    2012-07-05 06:32:41 +0000
+++ b/src/callproc.c    2012-07-05 18:35:48 +0000
@@ -1174,7 +1174,7 @@
        on that.  */
     pwd_var = xmalloc (i + 6);
 #else
-    pwd_var = (char *) alloca (i + 6);
+    pwd_var = alloca (i + 6);
 #endif
     temp = pwd_var + 4;
     memcpy (pwd_var, "PWD=", 4);
@@ -1242,7 +1242,7 @@
       }
 
     /* new_length + 2 to include PWD and terminating 0.  */
-    env = new_env = (char **) alloca ((new_length + 2) * sizeof (char *));
+    env = new_env = alloca ((new_length + 2) * sizeof *env);
     /* If we have a PWD envvar, pass one down,
        but with corrected value.  */
     if (egetenv ("PWD"))
@@ -1250,7 +1250,7 @@
 
     if (STRINGP (display))
       {
-       char *vdata = (char *) alloca (sizeof "DISPLAY=" + SBYTES (display));
+       char *vdata = alloca (sizeof "DISPLAY=" + SBYTES (display));
        strcpy (vdata, "DISPLAY=");
        strcat (vdata, SSDATA (display));
        new_env = add_env (env, new_env, vdata);

=== modified file 'src/charset.c'
--- a/src/charset.c     2012-07-05 06:32:41 +0000
+++ b/src/charset.c     2012-07-05 18:35:48 +0000
@@ -294,7 +294,7 @@
       else
        {
          if (! temp_charset_work)
-           temp_charset_work = xmalloc (sizeof (*temp_charset_work));
+           temp_charset_work = xmalloc (sizeof *temp_charset_work);
          if (control_flag == 1)
            {
              memset (temp_charset_work->table.decoder, -1,

=== modified file 'src/coding.c'
--- a/src/coding.c      2012-07-05 06:32:41 +0000
+++ b/src/coding.c      2012-07-05 18:35:48 +0000
@@ -1145,8 +1145,8 @@
 {
   if (STRING_BYTES_BOUND - coding->dst_bytes < bytes)
     string_overflow ();
-  coding->destination = (unsigned char *) xrealloc (coding->destination,
-                                                   coding->dst_bytes + bytes);
+  coding->destination = xrealloc (coding->destination,
+                                 coding->dst_bytes + bytes);
   coding->dst_bytes += bytes;
 }
 
@@ -7010,7 +7010,7 @@
     coding->charbuf = NULL;                                            \
     while (size > 1024)                                                        
\
       {                                                                        
\
-       coding->charbuf = (int *) alloca (sizeof (int) * size);         \
+       coding->charbuf = alloca (sizeof (int) * size);                 \
        if (coding->charbuf)                                            \
          break;                                                        \
        size >>= 1;                                                     \
@@ -9568,7 +9568,7 @@
 {
   Lisp_Object subsidiaries;
   ptrdiff_t base_name_len = SBYTES (SYMBOL_NAME (base));
-  char *buf = (char *) alloca (base_name_len + 6);
+  char *buf = alloca (base_name_len + 6);
   int i;
 
   memcpy (buf, SDATA (SYMBOL_NAME (base)), base_name_len);

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

=== modified file 'src/data.c'
--- a/src/data.c        2012-06-27 21:15:13 +0000
+++ b/src/data.c        2012-07-05 18:35:48 +0000
@@ -1463,8 +1463,7 @@
 static struct Lisp_Buffer_Local_Value *
 make_blv (struct Lisp_Symbol *sym, int forwarded, union Lisp_Val_Fwd 
valcontents)
 {
-  struct Lisp_Buffer_Local_Value *blv
-    = xmalloc (sizeof (struct Lisp_Buffer_Local_Value));
+  struct Lisp_Buffer_Local_Value *blv = xmalloc (sizeof *blv);
   Lisp_Object symbol;
   Lisp_Object tem;
 

=== modified file 'src/dispnew.c'
--- a/src/dispnew.c     2012-07-05 06:32:41 +0000
+++ b/src/dispnew.c     2012-07-05 18:35:48 +0000
@@ -2023,9 +2023,7 @@
 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 @@
 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 @@
 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 @@
   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 @@
          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 @@
   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;

=== modified file 'src/doc.c'
--- a/src/doc.c 2012-07-05 06:32:41 +0000
+++ b/src/doc.c 2012-07-05 18:35:48 +0000
@@ -577,14 +577,13 @@
       (0)
 #endif /* CANNOT_DUMP */
     {
-      name = (char *) alloca (SCHARS (filename) + 14);
+      name = alloca (SCHARS (filename) + 14);
       strcpy (name, "../etc/");
     }
   else
     {
       CHECK_STRING (Vdoc_directory);
-      name = (char *) alloca (SCHARS (filename)
-                         + SCHARS (Vdoc_directory) + 1);
+      name = alloca (SCHARS (filename) + SCHARS (Vdoc_directory) + 1);
       strcpy (name, SSDATA (Vdoc_directory));
     }
   strcat (name, SSDATA (filename));    /*** Add this line ***/
@@ -828,7 +827,7 @@
              ptrdiff_t offset = bufp - buf;
              if (STRING_BYTES_BOUND - 4 < bsize)
                string_overflow ();
-             buf = (char *) xrealloc (buf, bsize += 4);
+             buf = xrealloc (buf, bsize += 4);
              bufp = buf + offset;
              memcpy (bufp, "M-x ", 4);
              bufp += 4;
@@ -924,7 +923,7 @@
            ptrdiff_t offset = bufp - buf;
            if (STRING_BYTES_BOUND - length_byte < bsize)
              string_overflow ();
-           buf = (char *) xrealloc (buf, bsize += length_byte);
+           buf = xrealloc (buf, bsize += length_byte);
            bufp = buf + offset;
            memcpy (bufp, start, length_byte);
            bufp += length_byte;

=== modified file 'src/editfns.c'
--- a/src/editfns.c     2012-07-05 16:00:20 +0000
+++ b/src/editfns.c     2012-07-05 18:35:48 +0000
@@ -397,14 +397,14 @@
 
       /* First try with room for 40 overlays.  */
       noverlays = 40;
-      overlay_vec = (Lisp_Object *) alloca (noverlays * sizeof (Lisp_Object));
+      overlay_vec = alloca (noverlays * sizeof *overlay_vec);
       noverlays = overlays_around (posn, overlay_vec, noverlays);
 
       /* If there are more than 40,
         make enough space for all, and try again.  */
       if (noverlays > 40)
        {
-         overlay_vec = (Lisp_Object *) alloca (noverlays * sizeof 
(Lisp_Object));
+         overlay_vec = alloca (noverlays * sizeof *overlay_vec);
          noverlays = overlays_around (posn, overlay_vec, noverlays);
        }
       noverlays = sort_overlays (overlay_vec, noverlays, NULL);
@@ -1330,7 +1330,7 @@
       Lisp_Object login;
 
       login = Fuser_login_name (make_number (pw->pw_uid));
-      r = (char *) alloca (strlen (p) + SCHARS (login) + 1);
+      r = alloca (strlen (p) + SCHARS (login) + 1);
       memcpy (r, p, q - p);
       r[q - p] = 0;
       strcat (r, SSDATA (login));
@@ -2154,7 +2154,7 @@
   for (from = environ; *from; from++)
     continue;
   envptrs = from - environ + 2;
-  newenv = to = xmalloc (envptrs * sizeof (char *)
+  newenv = to = xmalloc (envptrs * sizeof *newenv
                         + (tzstring ? strlen (tzstring) + 4 : 0));
 
   /* Add TZSTRING to the end of environ, as a value for TZ.  */
@@ -3472,15 +3472,11 @@
       }
 #endif /* HAVE_MENUS */
       /* Copy the data so that it won't move when we GC.  */
-      if (! message_text)
-       {
-         message_text = xmalloc (80);
-         message_length = 80;
-       }
       if (SBYTES (val) > message_length)
        {
-         message_text = (char *) xrealloc (message_text, SBYTES (val));
-         message_length = SBYTES (val);
+         ptrdiff_t new_length = SBYTES (val) + 80;
+         message_text = xrealloc (message_text, new_length);
+         message_length = new_length;
        }
       memcpy (message_text, SDATA (val), SBYTES (val));
       message2 (message_text, SBYTES (val),

=== modified file 'src/emacs.c'
--- a/src/emacs.c       2012-07-05 06:32:41 +0000
+++ b/src/emacs.c       2012-07-05 18:35:48 +0000
@@ -1820,7 +1820,7 @@
 static void
 sort_args (int argc, char **argv)
 {
-  char **new = xmalloc (sizeof (char *) * argc);
+  char **new = xmalloc (argc * sizeof *new);
   /* 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-05 06:32:41 +0000
+++ b/src/eval.c        2012-07-05 18:35:48 +0000
@@ -138,7 +138,7 @@
 init_eval_once (void)
 {
   enum { size = 50 };
-  specpdl = xmalloc (size * sizeof (struct specbinding));
+  specpdl = xmalloc (size * sizeof *specpdl);
   specpdl_size = size;
   specpdl_ptr = specpdl;
   /* Don't forget to update docs (lispref node "Local Variables").  */
@@ -2803,7 +2803,8 @@
        {
          if (XSUBR (fun)->max_args > numargs)
            {
-             internal_args = (Lisp_Object *) alloca (XSUBR (fun)->max_args * 
sizeof (Lisp_Object));
+             internal_args = alloca (XSUBR (fun)->max_args
+                                     * sizeof *internal_args);
              memcpy (internal_args, args + 1, numargs * sizeof (Lisp_Object));
              for (i = numargs; i < XSUBR (fun)->max_args; i++)
                internal_args[i] = Qnil;

=== modified file 'src/fileio.c'
--- a/src/fileio.c      2012-07-05 04:16:11 +0000
+++ b/src/fileio.c      2012-07-05 18:35:48 +0000
@@ -336,7 +336,7 @@
 
   filename = FILE_SYSTEM_CASE (filename);
 #ifdef DOS_NT
-  beg = (char *) alloca (SBYTES (filename) + 1);
+  beg = alloca (SBYTES (filename) + 1);
   memcpy (beg, SSDATA (filename), SBYTES (filename) + 1);
 #else
   beg = SSDATA (filename);
@@ -510,7 +510,7 @@
       error ("Invalid handler in `file-name-handler-alist'");
     }
 
-  buf = (char *) alloca (SBYTES (file) + 10);
+  buf = alloca (SBYTES (file) + 10);
   file_name_as_directory (buf, SSDATA (file));
   return make_specified_string (buf, -1, strlen (buf),
                                STRING_MULTIBYTE (file));
@@ -575,7 +575,7 @@
       error ("Invalid handler in `file-name-handler-alist'");
     }
 
-  buf = (char *) alloca (SBYTES (directory) + 20);
+  buf = alloca (SBYTES (directory) + 20);
   directory_file_name (SSDATA (directory), buf);
   return make_specified_string (buf, -1, strlen (buf),
                                STRING_MULTIBYTE (directory));
@@ -878,7 +878,7 @@
     }
 
   /* Make a local copy of nm[] to protect it from GC in DECODE_FILE below.  */
-  nm = (char *) alloca (SBYTES (name) + 1);
+  nm = alloca (SBYTES (name) + 1);
   memcpy (nm, SSDATA (name), SBYTES (name) + 1);
 
 #ifdef DOS_NT
@@ -1186,7 +1186,7 @@
 #endif
          )
        {
-         char *temp = (char *) alloca (length);
+         char *temp = alloca (length);
          memcpy (temp, newdir, length - 1);
          temp[length - 1] = 0;
          newdir = temp;
@@ -1202,10 +1202,10 @@
   /* Reserve space for drive specifier and escape prefix, since either
      or both may need to be inserted.  (The Microsoft x86 compiler
      produces incorrect code if the following two lines are combined.)  */
-  target = (char *) alloca (tlen + 4);
+  target = alloca (tlen + 4);
   target += 4;
 #else  /* not DOS_NT */
-  target = (char *) alloca (tlen);
+  target = alloca (tlen);
 #endif /* not DOS_NT */
   *target = 0;
 
@@ -1415,7 +1415,7 @@
        unsigned char *ptr = (unsigned char *) strchr (user, '/');
        ptrdiff_t len = ptr ? ptr - user : strlen (user);
        /* Copy the user name into temp storage.  */
-       o = (unsigned char *) alloca (len + 1);
+       o = alloca (len + 1);
        memcpy (o, user, len);
        o[len] = 0;
 
@@ -1443,7 +1443,7 @@
   /* Now concatenate the directory and name to new space in the stack frame.  
*/
 
   tlen = (newdir ? strlen (newdir) + 1 : 0) + strlen (nm) + 1;
-  target = (unsigned char *) alloca (tlen);
+  target = alloca (tlen);
   *target = 0;
 
   if (newdir)
@@ -1593,7 +1593,7 @@
   /* Always work on a copy of the string, in case GC happens during
      decode of environment variables, causing the original Lisp_String
      data to be relocated.  */
-  nm = (char *) alloca (SBYTES (filename) + 1);
+  nm = alloca (SBYTES (filename) + 1);
   memcpy (nm, SDATA (filename), SBYTES (filename) + 1);
 
 #ifdef DOS_NT
@@ -1645,7 +1645,7 @@
          }
 
        /* Copy out the variable name.  */
-       target = (char *) alloca (s - o + 1);
+       target = alloca (s - o + 1);
        strncpy (target, o, s - o);
        target[s - o] = 0;
 #ifdef DOS_NT
@@ -1676,7 +1676,7 @@
 
   /* If substitution required, recopy the string and do it.  */
   /* Make space in stack frame for the new copy.  */
-  xnm = (char *) alloca (SBYTES (filename) + total + 1);
+  xnm = alloca (SBYTES (filename) + total + 1);
   x = xnm;
 
   /* Copy the rest of the name through, replacing $ constructs with values.  */
@@ -1708,7 +1708,7 @@
          }
 
        /* Copy out the variable name.  */
-       target = (char *) alloca (s - o + 1);
+       target = alloca (s - o + 1);
        strncpy (target, o, s - o);
        target[s - o] = 0;
 #ifdef DOS_NT

=== modified file 'src/filelock.c'
--- a/src/filelock.c    2012-07-05 06:32:41 +0000
+++ b/src/filelock.c    2012-07-05 18:35:48 +0000
@@ -294,7 +294,7 @@
    trailing period plus one for the digit after it plus one for the
    null.  */
 #define MAKE_LOCK_NAME(lock, file) \
-  (lock = (char *) alloca (SBYTES (file) + 2 + 1 + 1 + 1), \
+  (lock = alloca (SBYTES (file) + 2 + 1 + 1 + 1), \
    fill_in_lock_file_name (lock, (file)))
 
 static void

=== modified file 'src/fns.c'
--- a/src/fns.c 2012-07-05 06:32:41 +0000
+++ b/src/fns.c 2012-07-05 18:35:48 +0000
@@ -4347,7 +4347,7 @@
 
   /* The vector `used' is used to keep track of arguments that
      have been consumed.  */
-  used = (char *) alloca (nargs * sizeof *used);
+  used = alloca (nargs * sizeof *used);
   memset (used, 0, nargs * sizeof *used);
 
   /* See if there's a `:test TEST' among the arguments.  */

=== modified file 'src/font.c'
--- a/src/font.c        2012-06-30 09:13:54 +0000
+++ b/src/font.c        2012-07-05 18:35:48 +0000
@@ -3402,7 +3402,7 @@
     if (EQ (list->driver->type, driver->type))
       error ("Duplicated font driver: %s", SDATA (SYMBOL_NAME (driver->type)));
 
-  list = xmalloc (sizeof (struct font_driver_list));
+  list = xmalloc (sizeof *list);
   list->on = 0;
   list->driver = driver;
   list->next = NULL;
@@ -3552,7 +3552,7 @@
 
   if (! list)
     {
-      list = xmalloc (sizeof (struct font_data_list));
+      list = xmalloc (sizeof *list);
       list->driver = driver;
       list->next = f->font_data_list;
       f->font_data_list = list;

=== modified file 'src/fontset.c'
--- a/src/fontset.c     2012-06-28 07:50:50 +0000
+++ b/src/fontset.c     2012-07-05 18:35:48 +0000
@@ -1082,9 +1082,9 @@
         we convert "*" to "[^-]*" which is much faster in regular
         expression matching.  */
       if (ndashes < 14)
-       p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 
2 * nescs + 1);
+       p1 = regex = alloca (SBYTES (pattern) + 2 * nstars + 2 * nescs + 1);
       else
-       p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 
2 * nescs + 1);
+       p1 = regex = alloca (SBYTES (pattern) + 5 * nstars + 2 * nescs + 1);
 
       *p1++ = '^';
       for (p0 = SDATA (pattern); *p0; p0++)
@@ -1893,8 +1893,7 @@
 
   /* Recode fontsets realized on FRAME from the base fontset FONTSET
      in the table `realized'.  */
-  realized[0] = (Lisp_Object *) alloca (sizeof (Lisp_Object)
-                                       * ASIZE (Vfontset_table));
+  realized[0] = alloca (sizeof (Lisp_Object) * ASIZE (Vfontset_table));
   for (i = j = 0; i < ASIZE (Vfontset_table); i++)
     {
       elt = FONTSET_FROM_ID (i);
@@ -1905,8 +1904,7 @@
     }
   realized[0][j] = Qnil;
 
-  realized[1] = (Lisp_Object *) alloca (sizeof (Lisp_Object)
-                                       * ASIZE (Vfontset_table));
+  realized[1] = alloca (sizeof (Lisp_Object) * ASIZE (Vfontset_table));
   for (i = j = 0; ! NILP (realized[0][i]); i++)
     {
       elt = FONTSET_DEFAULT (realized[0][i]);

=== modified file 'src/frame.c'
--- a/src/frame.c       2012-06-28 12:29:37 +0000
+++ b/src/frame.c       2012-07-05 18:35:48 +0000
@@ -647,7 +647,7 @@
                        : NULL));
       if (!NILP (tty))
         {
-          name = (char *) alloca (SBYTES (tty) + 1);
+          name = alloca (SBYTES (tty) + 1);
           strncpy (name, SSDATA (tty), SBYTES (tty));
           name[SBYTES (tty)] = 0;
         }
@@ -658,7 +658,7 @@
                             : NULL));
       if (!NILP (tty_type))
         {
-          type = (char *) alloca (SBYTES (tty_type) + 1);
+          type = alloca (SBYTES (tty_type) + 1);
           strncpy (type, SSDATA (tty_type), SBYTES (tty_type));
           type[SBYTES (tty_type)] = 0;
         }
@@ -2762,8 +2762,8 @@
   for (tail = alist; CONSP (tail); tail = Fcdr (tail))
     i++;
 
-  parms = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
-  values = (Lisp_Object *) alloca (i * sizeof (Lisp_Object));
+  parms = alloca (i * sizeof *parms);
+  values = alloca (i * sizeof *values);
 
   /* Extract parm names and values into those vectors.  */
 
@@ -3624,17 +3624,17 @@
 
   /* Allocate space for the components, the dots which separate them,
      and the final '\0'.  Make them big enough for the worst case.  */
-  name_key = (char *) alloca (SBYTES (Vx_resource_name)
-                             + (STRINGP (component)
-                                ? SBYTES (component) : 0)
-                             + SBYTES (attribute)
-                             + 3);
+  name_key = alloca (SBYTES (Vx_resource_name)
+                    + (STRINGP (component)
+                       ? SBYTES (component) : 0)
+                    + SBYTES (attribute)
+                    + 3);
 
-  class_key = (char *) alloca (SBYTES (Vx_resource_class)
-                              + SBYTES (class)
-                              + (STRINGP (subclass)
-                                 ? SBYTES (subclass) : 0)
-                              + 3);
+  class_key = alloca (SBYTES (Vx_resource_class)
+                     + SBYTES (class)
+                     + (STRINGP (subclass)
+                        ? SBYTES (subclass) : 0)
+                     + 3);
 
   /* Start with emacs.FRAMENAME for the name (the specific one)
      and with `Emacs' for the class key (the general one).  */
@@ -3710,8 +3710,7 @@
   /* Allocate space for the components, the dots which separate them,
      and the final '\0'.  */
   SAFE_ALLOCA (name_key, char *, invocation_namelen + strlen (attribute) + 2);
-  class_key = (char *) alloca ((sizeof (EMACS_CLASS) - 1)
-                              + strlen (class) + 2);
+  class_key = alloca ((sizeof (EMACS_CLASS) - 1) + strlen (class) + 2);
 
   esprintf (name_key, "%s.%s", SSDATA (Vinvocation_name), attribute);
   sprintf (class_key, "%s.%s", EMACS_CLASS, class);

=== modified file 'src/fringe.c'
--- a/src/fringe.c      2012-07-05 06:32:41 +0000
+++ b/src/fringe.c      2012-07-05 18:35:48 +0000
@@ -1616,12 +1616,10 @@
                error ("No free fringe bitmap slots");
 
              i = max_fringe_bitmaps;
-             fringe_bitmaps
-               = ((struct fringe_bitmap **)
-                  xrealloc (fringe_bitmaps, bitmaps * sizeof *fringe_bitmaps));
-             fringe_faces
-               = (Lisp_Object *) xrealloc (fringe_faces,
-                                           bitmaps * sizeof *fringe_faces);
+             fringe_bitmaps = xrealloc (fringe_bitmaps,
+                                        bitmaps * sizeof *fringe_bitmaps);
+             fringe_faces = xrealloc (fringe_faces,
+                                      bitmaps * sizeof *fringe_faces);
 
              for (i = max_fringe_bitmaps; i < bitmaps; i++)
                {
@@ -1803,9 +1801,8 @@
 
   max_fringe_bitmaps = MAX_STANDARD_FRINGE_BITMAPS + 20;
 
-  fringe_bitmaps
-    = xzalloc (max_fringe_bitmaps * sizeof (struct fringe_bitmap *));
-  fringe_faces = xmalloc (max_fringe_bitmaps * sizeof (Lisp_Object));
+  fringe_bitmaps = xzalloc (max_fringe_bitmaps * sizeof *fringe_bitmaps);
+  fringe_faces = xmalloc (max_fringe_bitmaps * sizeof *fringe_faces);
 
   for (i = 0; i < max_fringe_bitmaps; i++)
     fringe_faces[i] = Qnil;

=== modified file 'src/ftfont.c'
--- a/src/ftfont.c      2012-06-28 07:50:27 +0000
+++ b/src/ftfont.c      2012-07-05 18:35:48 +0000
@@ -392,7 +392,7 @@
          args[1] = Qequal;
          ft_face_cache = Fmake_hash_table (2, args);
        }
-      cache_data = xmalloc (sizeof (struct ftfont_cache_data));
+      cache_data = xmalloc (sizeof *cache_data);
       cache_data->ft_face = NULL;
       cache_data->fc_charset = NULL;
       val = make_save_value (NULL, 0);
@@ -657,7 +657,7 @@
 static struct OpenTypeSpec *
 ftfont_get_open_type_spec (Lisp_Object otf_spec)
 {
-  struct OpenTypeSpec *spec = malloc (sizeof (struct OpenTypeSpec));
+  struct OpenTypeSpec *spec = malloc (sizeof *spec);
   Lisp_Object val;
   int i, j, negative;
 
@@ -696,7 +696,7 @@
       spec->features[i] =
        (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XINT (len)
         ? 0
-        : malloc (sizeof (int) * XINT (len)));
+        : malloc (XINT (len) * sizeof *spec->features[i]));
       if (! spec->features[i])
        {
          if (i > 0 && spec->features[0])
@@ -2460,15 +2460,16 @@
   if (gstring.allocated == 0)
     {
       gstring.glyph_size = sizeof (MFLTGlyph);
-      gstring.glyphs = xnmalloc (len * 2, sizeof (MFLTGlyph));
+      gstring.glyphs = xnmalloc (len * 2, sizeof *gstring.glyphs);
       gstring.allocated = len * 2;
     }
   else if (gstring.allocated < len * 2)
     {
-      gstring.glyphs = xnrealloc (gstring.glyphs, len * 2, sizeof (MFLTGlyph));
+      gstring.glyphs = xnrealloc (gstring.glyphs, len * 2,
+                                 sizeof *gstring.glyphs);
       gstring.allocated = len * 2;
     }
-  memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len);
+  memset (gstring.glyphs, 0, len * sizeof *gstring.glyphs);
   for (i = 0; i < len; i++)
     {
       Lisp_Object g = LGSTRING_GLYPH (lgstring, i);

=== modified file 'src/ftxfont.c'
--- a/src/ftxfont.c     2012-01-19 07:21:25 +0000
+++ b/src/ftxfont.c     2012-07-05 18:35:48 +0000
@@ -90,7 +90,7 @@
        }
     }
 
-  new = malloc (sizeof (struct ftxfont_frame_data));
+  new = malloc (sizeof *new);
   if (! new)
     return NULL;
   new->next = this;

=== modified file 'src/gmalloc.c'
--- a/src/gmalloc.c     2012-06-26 01:05:39 +0000
+++ b/src/gmalloc.c     2012-07-05 18:35:48 +0000
@@ -1616,7 +1616,7 @@
          break;
       if (l == NULL)
        {
-         l = malloc (sizeof (struct alignlist));
+         l = malloc (sizeof *l);
          if (l != NULL)
            {
              l->next = _aligned_blocks;
@@ -1811,7 +1811,7 @@
   struct hdr *hdr;
 
   __malloc_hook = old_malloc_hook;
-  hdr = malloc (sizeof (struct hdr) + size + 1);
+  hdr = malloc (sizeof *hdr + size + 1);
   __malloc_hook = mallochook;
   if (hdr == NULL)
     return NULL;
@@ -1842,7 +1842,7 @@
   __free_hook = old_free_hook;
   __malloc_hook = old_malloc_hook;
   __realloc_hook = old_realloc_hook;
-  hdr = realloc (hdr, sizeof (struct hdr) + size + 1);
+  hdr = realloc (hdr, sizeof *hdr + size + 1);
   __free_hook = freehook;
   __malloc_hook = mallochook;
   __realloc_hook = reallochook;

=== modified file 'src/gtkutil.c'
--- a/src/gtkutil.c     2012-07-05 15:44:53 +0000
+++ b/src/gtkutil.c     2012-07-05 18:35:48 +0000
@@ -215,7 +215,7 @@
     }
   else
     {
-      wv = xmalloc (sizeof (widget_value));
+      wv = xmalloc (sizeof *wv);
       malloc_cpt++;
     }
   memset (wv, 0, sizeof (widget_value));
@@ -2057,7 +2057,7 @@
 {
   if (! cl_data)
     {
-      cl_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;
@@ -2357,7 +2357,7 @@
   if (utf8_label) g_free (utf8_label);
   if (utf8_key) g_free (utf8_key);
 
-  cb_data = xmalloc (sizeof (xg_menu_item_cb_data));
+  cb_data = xmalloc (sizeof *cb_data);
 
   xg_list_insert (&xg_menu_item_cb_list, &cb_data->ptrs);
 
@@ -4336,7 +4336,7 @@
 {
 #ifdef HAVE_GTK3
   int ret = 0;
-  if (GTK_IS_BOX (vb)) 
+  if (GTK_IS_BOX (vb))
     {
       GtkOrientation ori = gtk_orientable_get_orientation (GTK_ORIENTABLE 
(vb));
       ret = (ori == GTK_ORIENTATION_HORIZONTAL && is_horizontal)

=== modified file 'src/image.c'
--- a/src/image.c       2012-07-05 06:32:41 +0000
+++ b/src/image.c       2012-07-05 18:35:48 +0000
@@ -1356,9 +1356,7 @@
       /* This isn't called frequently so we get away with simply
         reallocating the color vector to the needed size, here.  */
       ptrdiff_t ncolors = img->ncolors + 1;
-      img->colors =
-       (unsigned long *) xrealloc (img->colors,
-                                   ncolors * sizeof *img->colors);
+      img->colors = xrealloc (img->colors, ncolors * sizeof *img->colors);
       img->colors[ncolors - 1] = color.pixel;
       img->ncolors = ncolors;
       result = color.pixel;
@@ -2500,7 +2498,7 @@
 
   w1 = (width + 7) / 8;         /* nb of 8bits elt in X bitmap */
   w2 = ((width + 15) / 16) * 2; /* nb of 16bits elt in W32 bitmap */
-  bits = (unsigned char *) alloca (height * w2);
+  bits = alloca (height * w2);
   memset (bits, 0, height * w2);
   for (i = 0; i < height; i++)
     {
@@ -2927,7 +2925,7 @@
              char *p;
              int nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR;
 
-             p = bits = (char *) alloca (nbytes * img->height);
+             p = bits = alloca (nbytes * img->height);
              for (i = 0; i < img->height; ++i, p += nbytes)
                {
                  Lisp_Object line = AREF (data, i);
@@ -2950,7 +2948,7 @@
             invertedBits = bits;
             nbytes = (img->width + BITS_PER_CHAR - 1) / BITS_PER_CHAR
               * img->height;
-            bits = (char *) alloca (nbytes);
+            bits = alloca (nbytes);
             for (i = 0; i < nbytes; i++)
               bits[i] = XBM_BIT_SHUFFLE (invertedBits[i]);
           }
@@ -3422,7 +3420,7 @@
 
       /* Allocate an XpmColorSymbol array.  */
       size = attrs.numsymbols * sizeof *xpm_syms;
-      xpm_syms = (XpmColorSymbol *) alloca (size);
+      xpm_syms = alloca (size);
       memset (xpm_syms, 0, size);
       attrs.colorsymbols = xpm_syms;
 
@@ -3445,14 +3443,14 @@
          color = XCDR (XCAR (tail));
          if (STRINGP (name))
            {
-             xpm_syms[i].name = (char *) alloca (SCHARS (name) + 1);
+             xpm_syms[i].name = alloca (SCHARS (name) + 1);
              strcpy (xpm_syms[i].name, SSDATA (name));
            }
          else
            xpm_syms[i].name = empty_string;
          if (STRINGP (color))
            {
-             xpm_syms[i].value = (char *) alloca (SCHARS (color) + 1);
+             xpm_syms[i].value = alloca (SCHARS (color) + 1);
              strcpy (xpm_syms[i].value, SSDATA (color));
            }
          else
@@ -6449,8 +6447,7 @@
        a default color, and we don't have to care about which colors
        can be freed safely, and which can't.  */
     init_color_table ();
-    colors = (unsigned long *) alloca (cinfo.actual_number_of_colors
-                                      * sizeof *colors);
+    colors = alloca (cinfo.actual_number_of_colors * sizeof *colors);
 
     for (i = 0; i < cinfo.actual_number_of_colors; ++i)
       {

=== modified file 'src/keyboard.c'
--- a/src/keyboard.c    2012-07-05 06:32:41 +0000
+++ b/src/keyboard.c    2012-07-05 18:35:48 +0000
@@ -480,7 +480,7 @@
   if (current_kboard->immediate_echo)
     {
       int size = KEY_DESCRIPTION_SIZE + 100;
-      char *buffer = (char *) alloca (size);
+      char *buffer = alloca (size);
       char *ptr = buffer;
       Lisp_Object echo_string;
 
@@ -502,7 +502,7 @@
            {
              int offset = ptr - buffer;
              size = max (2 * size, size + nbytes);
-             buffer = (char *) alloca (size);
+             buffer = alloca (size);
              ptr = buffer + offset;
            }
 
@@ -520,7 +520,7 @@
            {
              int offset = ptr - buffer;
              size += len;
-             buffer = (char *) alloca (size);
+             buffer = alloca (size);
              ptr = buffer + offset;
            }
 
@@ -884,7 +884,7 @@
 void
 push_kboard (struct kboard *k)
 {
-  struct kboard_stack *p = xmalloc (sizeof (struct kboard_stack));
+  struct kboard_stack *p = xmalloc (sizeof *p);
 
   p->next = kboard_stack;
   p->kboard = current_kboard;
@@ -6196,8 +6196,7 @@
   /* Since BASE could contain nulls, we can't use intern here; we have
      to use Fintern, which expects a genuine Lisp_String, and keeps a
      reference to it.  */
-  char *new_mods
-    = (char *) alloca (sizeof ("A-C-H-M-S-s-down-drag-double-triple-"));
+  char new_mods[sizeof "A-C-H-M-S-s-down-drag-double-triple-"];
   int mod_len;
 
   {
@@ -7280,7 +7279,7 @@
       /* Already added.  */
       return;
 
-  p = xmalloc (sizeof (struct user_signal_info));
+  p = xmalloc (sizeof *p);
   p->sig = sig;
   p->name = xstrdup (name);
   p->npending = 0;
@@ -7506,7 +7505,7 @@
        Lisp_Object tem;
        ptrdiff_t nminor;
        nminor = current_minor_maps (NULL, &tmaps);
-       maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0]));
+       maps = alloca ((nminor + 3) * sizeof *maps);
        nmaps = 0;
        if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem))
          maps[nmaps++] = tem;
@@ -8033,7 +8032,7 @@
   if (!NILP (Voverriding_local_map_menu_flag))
     {
       /* Yes, use them (if non-nil) as well as the global map.  */
-      maps = (Lisp_Object *) alloca (3 * sizeof (maps[0]));
+      maps = alloca (3 * sizeof *maps);
       nmaps = 0;
       if (!NILP (KVAR (current_kboard, Voverriding_terminal_local_map)))
        maps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map);
@@ -8050,7 +8049,7 @@
       Lisp_Object tem;
       ptrdiff_t nminor;
       nminor = current_minor_maps (NULL, &tmaps);
-      maps = (Lisp_Object *) alloca ((nminor + 3) * sizeof (maps[0]));
+      maps = alloca ((nminor + 3) * sizeof *maps);
       nmaps = 0;
       if (tem = get_local_map (PT, current_buffer, Qkeymap), !NILP (tem))
        maps[nmaps++] = tem;
@@ -8475,8 +8474,7 @@
       && !EQ (XCAR (prev_event), Qtool_bar))
     {
       /* Display the menu and get the selection.  */
-      Lisp_Object *realmaps
-       = (Lisp_Object *) alloca (nmaps * sizeof (Lisp_Object));
+      Lisp_Object *realmaps = alloca (nmaps * sizeof *realmaps);
       Lisp_Object value;
       ptrdiff_t nmaps1 = 0;
 
@@ -8570,7 +8568,7 @@
   if (width + 4 > read_char_minibuf_menu_width)
     {
       read_char_minibuf_menu_text
-       = (char *) xrealloc (read_char_minibuf_menu_text, width + 4);
+       = xrealloc (read_char_minibuf_menu_text, width + 4);
       read_char_minibuf_menu_width = width + 4;
     }
   menu = read_char_minibuf_menu_text;
@@ -9177,8 +9175,8 @@
     {
       if (2 > nmaps_allocated)
        {
-         submaps = (Lisp_Object *) alloca (2 * sizeof (submaps[0]));
-         defs    = (Lisp_Object *) alloca (2 * sizeof (defs[0]));
+         submaps = alloca (2 * sizeof *submaps);
+         defs    = alloca (2 * sizeof *defs);
          nmaps_allocated = 2;
        }
       submaps[nmaps++] = KVAR (current_kboard, Voverriding_terminal_local_map);
@@ -9187,8 +9185,8 @@
     {
       if (2 > nmaps_allocated)
        {
-         submaps = (Lisp_Object *) alloca (2 * sizeof (submaps[0]));
-         defs    = (Lisp_Object *) alloca (2 * sizeof (defs[0]));
+         submaps = alloca (2 * sizeof *submaps);
+         defs    = alloca (2 * sizeof *defs);
          nmaps_allocated = 2;
        }
       submaps[nmaps++] = Voverriding_local_map;
@@ -9204,8 +9202,8 @@
 
       if (total > nmaps_allocated)
        {
-         submaps = (Lisp_Object *) alloca (total * sizeof (submaps[0]));
-         defs    = (Lisp_Object *) alloca (total * sizeof (defs[0]));
+         submaps = alloca (total * sizeof *submaps);
+         defs    = alloca (total * sizeof *defs);
          nmaps_allocated = total;
        }
 
@@ -12187,7 +12185,7 @@
   Vdebug_on_event = intern_c_string ("sigusr2");
 
   /* Create the initial keyboard.  */
-  initial_kboard = xmalloc (sizeof (KBOARD));
+  initial_kboard = xmalloc (sizeof *initial_kboard);
   init_kboard (initial_kboard);
   /* Vwindow_system is left at t for now.  */
   initial_kboard->next_kboard = all_kboards;

=== modified file 'src/keymap.c'
--- a/src/keymap.c      2012-07-03 18:24:42 +0000
+++ b/src/keymap.c      2012-07-05 18:35:48 +0000
@@ -1478,7 +1478,7 @@
                /* Use malloc here.  See the comment above this function.
                   Avoid realloc here; it causes spurious traps on GNU/Linux 
[KFS] */
                BLOCK_INPUT;
-               newmodes = (Lisp_Object *) malloc (allocsize);
+               newmodes = malloc (allocsize);
                if (newmodes)
                  {
                    if (cmm_modes)
@@ -1490,7 +1490,7 @@
                    cmm_modes = newmodes;
                  }
 
-               newmaps = (Lisp_Object *) malloc (allocsize);
+               newmaps = malloc (allocsize);
                if (newmaps)
                  {
                    if (cmm_maps)
@@ -2923,7 +2923,7 @@
          if (!SYMBOLP (modes[i]))
            abort ();
 
-         p = title = (char *) alloca (42 + SCHARS (SYMBOL_NAME (modes[i])));
+         p = title = alloca (42 + SCHARS (SYMBOL_NAME (modes[i])));
          *p++ = '\f';
          *p++ = '\n';
          *p++ = '`';

=== modified file 'src/lread.c'
--- a/src/lread.c       2012-07-05 06:32:41 +0000
+++ b/src/lread.c       2012-07-05 18:35:48 +0000
@@ -1479,7 +1479,7 @@
         this path element/specified file name and any possible suffix.  */
       want_length = max_suffix_len + SBYTES (filename);
       if (fn_size <= want_length)
-       fn = (char *) alloca (fn_size = 100 + want_length);
+       fn = alloca (fn_size = 100 + want_length);
 
       /* Loop over suffixes.  */
       for (tail = NILP (suffixes) ? Fcons (empty_unibyte_string, Qnil) : 
suffixes;
@@ -2630,8 +2630,7 @@
                }
              if (nskip > saved_doc_string_size)
                {
-                 saved_doc_string = (char *) xrealloc (saved_doc_string,
-                                                       nskip + extra);
+                 saved_doc_string = xrealloc (saved_doc_string, nskip + extra);
                  saved_doc_string_size = nskip + extra;
                }
 
@@ -2894,8 +2893,7 @@
                ptrdiff_t offset = p - read_buffer;
                if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
                  memory_full (SIZE_MAX);
-               read_buffer = (char *) xrealloc (read_buffer,
-                                                read_buffer_size * 2);
+               read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
                read_buffer_size *= 2;
                p = read_buffer + offset;
                end = read_buffer + read_buffer_size;
@@ -3029,8 +3027,7 @@
                  ptrdiff_t offset = p - read_buffer;
                  if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
                    memory_full (SIZE_MAX);
-                 read_buffer = (char *) xrealloc (read_buffer,
-                                                  read_buffer_size * 2);
+                 read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
                  read_buffer_size *= 2;
                  p = read_buffer + offset;
                  end = read_buffer + read_buffer_size;
@@ -3060,8 +3057,7 @@
              ptrdiff_t offset = p - read_buffer;
              if (min (PTRDIFF_MAX, SIZE_MAX) / 2 < read_buffer_size)
                memory_full (SIZE_MAX);
-             read_buffer = (char *) xrealloc (read_buffer,
-                                              read_buffer_size * 2);
+             read_buffer = xrealloc (read_buffer, read_buffer_size * 2);
              read_buffer_size *= 2;
              p = read_buffer + offset;
              end = read_buffer + read_buffer_size;

=== modified file 'src/macros.c'
--- a/src/macros.c      2012-06-16 12:24:15 +0000
+++ b/src/macros.c      2012-07-05 18:35:48 +0000
@@ -63,8 +63,7 @@
 
   if (!current_kboard->kbd_macro_buffer)
     {
-      current_kboard->kbd_macro_buffer
-       = (Lisp_Object *)xmalloc (30 * sizeof (Lisp_Object));
+      current_kboard->kbd_macro_buffer = xmalloc (30 * sizeof (Lisp_Object));
       current_kboard->kbd_macro_bufsize = 30;
     }
   update_mode_lines++;
@@ -205,8 +204,7 @@
              < kb->kbd_macro_bufsize)
            memory_full (SIZE_MAX);
          nbytes = kb->kbd_macro_bufsize * (2 * sizeof *kb->kbd_macro_buffer);
-         kb->kbd_macro_buffer
-           = (Lisp_Object *) xrealloc (kb->kbd_macro_buffer, nbytes);
+         kb->kbd_macro_buffer = xrealloc (kb->kbd_macro_buffer, nbytes);
          kb->kbd_macro_bufsize *= 2;
          kb->kbd_macro_ptr = kb->kbd_macro_buffer + ptr_offset;
          kb->kbd_macro_end = kb->kbd_macro_buffer + end_offset;

=== modified file 'src/menu.c'
--- a/src/menu.c        2012-06-30 09:13:54 +0000
+++ b/src/menu.c        2012-07-05 18:35:48 +0000
@@ -632,8 +632,7 @@
   widget_value **submenu_stack;
   int panes_seen = 0;
 
-  submenu_stack
-    = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
+  submenu_stack = alloca (menu_items_used * sizeof *submenu_stack);
   wv = xmalloc_widget_value ();
   wv->name = "menu";
   wv->value = 0;
@@ -893,7 +892,7 @@
   int i;
 
   entry = Qnil;
-  subprefix_stack = (Lisp_Object *) alloca (menu_bar_items_used * sizeof 
(Lisp_Object));
+  subprefix_stack = alloca (menu_bar_items_used * sizeof *subprefix_stack);
   prefix = Qnil;
   i = 0;
 

=== modified file 'src/nsfns.m'
--- a/src/nsfns.m       2012-06-29 01:35:32 +0000
+++ b/src/nsfns.m       2012-07-05 18:35:48 +0000
@@ -1203,8 +1203,7 @@
   f->terminal = dpyinfo->terminal;
 
   f->output_method = output_ns;
-  f->output_data.ns = (struct ns_output *)xmalloc (sizeof 
*(f->output_data.ns));
-  memset (f->output_data.ns, 0, sizeof *(f->output_data.ns));
+  f->output_data.ns = xzalloc (sizeof *f->output_data.ns);
 
   FRAME_FONTSET (f) = -1;
 

=== modified file 'src/nsfont.m'
--- a/src/nsfont.m      2012-02-10 18:58:48 +0000
+++ b/src/nsfont.m      2012-07-05 18:35:48 +0000
@@ -152,7 +152,7 @@
        [fdAttrs setObject: tdict forKey: NSFontTraitsAttribute];
 
     fdesc = [NSFontDescriptor fontDescriptorWithFontAttributes: fdAttrs];
-    if (family != nil) 
+    if (family != nil)
       {
        fdesc = [fdesc fontDescriptorWithFamily: family];
       }
@@ -779,14 +779,8 @@
   if (!font)
     return Qnil; /* FIXME: other terms do, but return Qnil causes segfault */
 
-  font_info->glyphs = (unsigned short **)
-    xmalloc (0x100 * sizeof (unsigned short *));
-  font_info->metrics = (struct font_metrics **)
-    xmalloc (0x100 * sizeof (struct font_metrics *));
-  if (!font_info->glyphs || !font_info->metrics)
-    return Qnil;
-  memset (font_info->glyphs, 0, 0x100 * sizeof (unsigned short *));
-  memset (font_info->metrics, 0, 0x100 * sizeof (struct font_metrics *));
+  font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs);
+  font_info->metrics = xzalloc (0x100 * sizeof *font_info->metrics);
 
   BLOCK_INPUT;
 
@@ -831,8 +825,7 @@
     [font_info->nsfont retain];
 
     /* set up ns_font (defined in nsgui.h) */
-    font_info->name = (char *)xmalloc (strlen (fontName)+1);
-    strcpy (font_info->name, fontName);
+    font_info->name = xstrdup (fontName);
     font_info->bold = [fontMgr traitsOfFont: nsfont] & NSBoldFontMask;
     font_info->ital =
       synthItal || ([fontMgr traitsOfFont: nsfont] & NSItalicFontMask);
@@ -1371,8 +1364,7 @@
  BLOCK_INPUT;
  sfont = [font_info->nsfont screenFont];
 
-  font_info->metrics[block] = xmalloc (0x100 * sizeof (struct font_metrics));
-  memset (font_info->metrics[block], 0, 0x100 * sizeof (struct font_metrics));
+  font_info->metrics[block] = xzalloc (0x100 * sizeof (struct font_metrics));
   if (!(font_info->metrics[block]))
     abort ();
 
@@ -1417,7 +1409,7 @@
   maxChar = 0;
   maxGlyph = 0;
   dict = [NSMutableDictionary new];
-  cglyphs = (CGGlyph *)xmalloc (c * sizeof (CGGlyph));
+  cglyphs = xmalloc (c * sizeof (CGGlyph));
   return self;
 }
 

=== modified file 'src/nsmenu.m'
--- a/src/nsmenu.m      2012-06-29 01:35:32 +0000
+++ b/src/nsmenu.m      2012-07-05 18:35:48 +0000
@@ -190,8 +190,7 @@
       ptrdiff_t specpdl_count = SPECPDL_INDEX ();
       int previous_menu_items_used = f->menu_bar_items_used;
       Lisp_Object *previous_items
-       = (Lisp_Object *) alloca (previous_menu_items_used
-                                 * sizeof (Lisp_Object));
+       = alloca (previous_menu_items_used * sizeof *previous_items);
 
       /* lisp preliminaries */
       buffer = XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer;
@@ -231,11 +230,11 @@
 
       menu_items = f->menu_bar_vector;
       menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
-      submenu_start = (int *) alloca (ASIZE (items) * sizeof (int *));
-      submenu_end = (int *) alloca (ASIZE (items) * sizeof (int *));
-      submenu_n_panes = (int *) alloca (ASIZE (items) * sizeof (int));
-      submenu_top_level_items
-       = (int *) alloca (ASIZE (items) * sizeof (int *));
+      submenu_start = alloca (ASIZE (items) * sizeof *submenu_start);
+      submenu_end = alloca (ASIZE (items) * sizeof *submenu_end);
+      submenu_n_panes = alloca (ASIZE (items) * sizeof *submenu_n_panes);
+      submenu_top_level_items = alloca (ASIZE (items)
+                                       * sizeof *submenu_top_level_items);
       init_menu_items ();
       for (i = 0; i < ASIZE (items); i += 4)
        {
@@ -814,9 +813,9 @@
   {
   widget_value *save_wv = 0, *prev_wv = 0;
   widget_value **submenu_stack
-    = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
+    = alloca (menu_items_used * sizeof *submenu_stack);
 /*   Lisp_Object *subprefix_stack
-       = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object)); */
+       = alloca (menu_items_used * sizeof *subprefix_stack); */
   int submenu_depth = 0;
   int first_pane = 1;
   int i;

=== modified file 'src/nsterm.m'
--- a/src/nsterm.m      2012-06-30 21:35:20 +0000
+++ b/src/nsterm.m      2012-07-05 18:35:48 +0000
@@ -1323,8 +1323,7 @@
     {
       color_table->size = NS_COLOR_CAPACITY;
       color_table->avail = 1; /* skip idx=0 as marker */
-      color_table->colors
-       = (NSColor **)xmalloc (color_table->size * sizeof (NSColor *));
+      color_table->colors = xmalloc (color_table->size * sizeof (NSColor *));
       color_table->colors[0] = nil;
       color_table->empty_indices = [[NSMutableSet alloc] init];
     }
@@ -2245,17 +2244,9 @@
   /* grow bimgs if needed */
   if (nBimgs < max_used_fringe_bitmap)
     {
-      EmacsImage **newBimgs
-       = xmalloc (max_used_fringe_bitmap * sizeof (EmacsImage *));
-      memset (newBimgs, 0, max_used_fringe_bitmap * sizeof (EmacsImage *));
-
-      if (nBimgs)
-        {
-          memcpy (newBimgs, bimgs, nBimgs * sizeof (EmacsImage *));
-          xfree (bimgs);
-        }
-
-      bimgs = newBimgs;
+      bimgs = xrealloc (bimgs, max_used_fringe_bitmap * sizeof *bimgs);
+      memset (bimgs + nBimgs, 0,
+             (max_used_fringe_bitmap - nBimgs) * sizeof *bimgs);
       nBimgs = max_used_fringe_bitmap;
     }
 
@@ -3889,8 +3880,7 @@
                                                  NSColorSpaceFromDepth 
(depth)];
     dpyinfo->n_planes = NSBitsPerPixelFromDepth (depth);
     dpyinfo->image_cache = make_image_cache ();
-    dpyinfo->color_table
-      = (struct ns_color_table *)xmalloc (sizeof (struct ns_color_table));
+    dpyinfo->color_table = xmalloc (sizeof *dpyinfo->color_table);
     dpyinfo->color_table->colors = NULL;
     dpyinfo->root_window = 42; /* a placeholder.. */
 
@@ -4071,13 +4061,12 @@
                                          selector: @selector (logNotification:)
                                              name: nil object: nil]; */
 
-  dpyinfo = (struct ns_display_info *)xmalloc (sizeof (struct 
ns_display_info));
-  memset (dpyinfo, 0, sizeof (struct ns_display_info));
+  dpyinfo = xzalloc (sizeof *dpyinfo);
 
   ns_initialize_display_info (dpyinfo);
   terminal = ns_create_terminal (dpyinfo);
 
-  terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
+  terminal->kboard = xmalloc (sizeof *terminal->kboard);
   init_kboard (terminal->kboard);
   KVAR (terminal->kboard, Vwindow_system) = Qns;
   terminal->kboard->next_kboard = all_kboards;
@@ -4098,7 +4087,7 @@
   dpyinfo->name_list_element = XCAR (ns_display_name_list);
 
   /* 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;
 
@@ -5355,8 +5344,7 @@
             char *pos = strstr (t, "  —  ");
             if (pos)
               *pos = '\0';
-            old_title = (char *) xmalloc (strlen (t) + 1);
-            strcpy (old_title, t);
+            old_title = xstrdup (t);
           }
         size_title = xmalloc (strlen (old_title) + 40);
        esprintf (size_title, "%s  —  (%d x %d)", old_title, cols, rows);
@@ -6076,7 +6064,7 @@
 
   if (nr_screens == 1)
     return [super constrainFrameRect:frameRect toScreen:screen];
-  
+
   if (f->output_data.ns->dont_constrain
       || ns_menu_bar_should_be_hidden ())
     return frameRect;

=== modified file 'src/print.c'
--- a/src/print.c       2012-07-05 06:32:41 +0000
+++ b/src/print.c       2012-07-05 18:35:48 +0000
@@ -173,8 +173,7 @@
        if (print_buffer_pos != print_buffer_pos_byte                   \
           && NILP (BVAR (current_buffer, enable_multibyte_characters)))        
\
         {                                                              \
-          unsigned char *temp                                          \
-            = (unsigned char *) alloca (print_buffer_pos + 1);         \
+          unsigned char *temp = alloca (print_buffer_pos + 1);         \
           copy_text ((unsigned char *) print_buffer, temp,             \
                      print_buffer_pos_byte, 1, 0);                     \
           insert_1_both ((char *) temp, print_buffer_pos,              \

=== modified file 'src/process.c'
--- a/src/process.c     2012-07-05 06:32:41 +0000
+++ b/src/process.c     2012-07-05 18:35:48 +0000
@@ -1365,7 +1365,7 @@
     val = Vcoding_system_for_read;
     if (NILP (val))
       {
-       args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2);
+       args2 = alloca ((nargs + 1) * sizeof *args2);
        args2[0] = Qstart_process;
        for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
        GCPRO2 (proc, current_dir);
@@ -1384,7 +1384,7 @@
       {
        if (EQ (coding_systems, Qt))
          {
-           args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2);
+           args2 = alloca ((nargs + 1) * sizeof *args2);
            args2[0] = Qstart_process;
            for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
            GCPRO2 (proc, current_dir);
@@ -1478,7 +1478,7 @@
 
       /* Now that everything is encoded we can collect the strings into
         NEW_ARGV.  */
-      new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *));
+      new_argv = alloca ((nargs - 1) * sizeof *new_argv);
       new_argv[nargs - 2] = 0;
 
       for (i = nargs - 2; i-- != 0; )
@@ -5037,7 +5037,7 @@
   ptrdiff_t count = SPECPDL_INDEX ();
   Lisp_Object odeactivate;
 
-  chars = (char *) alloca (carryover + readmax);
+  chars = alloca (carryover + readmax);
   if (carryover)
     /* See the comment above.  */
     memcpy (chars, SDATA (p->decoding_buf), carryover);
@@ -7083,8 +7083,7 @@
     return;
 
   if (!proc_decode_coding_system[inch])
-    proc_decode_coding_system[inch]
-      = xmalloc (sizeof (struct coding_system));
+    proc_decode_coding_system[inch] = xmalloc (sizeof (struct coding_system));
   coding_system = p->decode_coding_system;
   if (! NILP (p->filter))
     ;
@@ -7096,8 +7095,7 @@
   setup_coding_system (coding_system, proc_decode_coding_system[inch]);
 
   if (!proc_encode_coding_system[outch])
-    proc_encode_coding_system[outch]
-      = xmalloc (sizeof (struct coding_system));
+    proc_encode_coding_system[outch] = xmalloc (sizeof (struct coding_system));
   setup_coding_system (p->encode_coding_system,
                       proc_encode_coding_system[outch]);
 #endif

=== modified file 'src/ralloc.c'
--- a/src/ralloc.c      2012-06-29 06:28:37 +0000
+++ b/src/ralloc.c      2012-07-05 18:35:48 +0000
@@ -396,7 +396,7 @@
   register bloc_ptr new_bloc;
   register heap_ptr heap;
 
-  if (! (new_bloc = (bloc_ptr) malloc (BLOC_PTR_SIZE))
+  if (! (new_bloc = malloc (BLOC_PTR_SIZE))
       || ! (new_bloc->data = obtain (break_value, size)))
     {
       free (new_bloc);

=== modified file 'src/regex.c'
--- a/src/regex.c       2012-07-04 00:36:28 +0000
+++ b/src/regex.c       2012-07-05 18:35:48 +0000
@@ -212,8 +212,7 @@
 static void *
 xmalloc (size_t size)
 {
-  register void *val;
-  val = (void *) malloc (size);
+  void *val = malloc (size);
   if (!val && size)
     {
       write (2, "virtual memory exhausted\n", 25);
@@ -225,13 +224,13 @@
 static void *
 xrealloc (void *block, size_t size)
 {
-  register void *val;
+  void *val;
   /* We must call malloc explicitly when BLOCK is 0, since some
      reallocs don't do this.  */
   if (! block)
-    val = (void *) malloc (size);
+    val = malloc (size);
   else
-    val = (void *) realloc (block, size);
+    val = realloc (block, size);
   if (!val && size)
     {
       write (2, "virtual memory exhausted\n", 25);
@@ -1386,7 +1385,7 @@
 #ifdef MATCH_MAY_ALLOCATE
 # define INIT_FAIL_STACK()                                             \
   do {                                                                 \
-    fail_stack.stack = (fail_stack_elt_t *)                            \
+    fail_stack.stack =                                                 \
       REGEX_ALLOCATE_STACK (INIT_FAILURE_ALLOC * TYPICAL_FAILURE_SIZE  \
                            * sizeof (fail_stack_elt_t));               \
                                                                        \
@@ -1429,8 +1428,7 @@
     >= re_max_failures * TYPICAL_FAILURE_SIZE)                         \
    ? 0                                                                 \
    : ((fail_stack).stack                                               \
-      = (fail_stack_elt_t *)                                           \
-       REGEX_REALLOCATE_STACK ((fail_stack).stack,                     \
+      = REGEX_REALLOCATE_STACK ((fail_stack).stack,                    \
          (fail_stack).size * sizeof (fail_stack_elt_t),                \
          MIN (re_max_failures * TYPICAL_FAILURE_SIZE,                  \
               ((fail_stack).size * sizeof (fail_stack_elt_t)           \
@@ -2141,12 +2139,7 @@
 extend_range_table_work_area (struct range_table_work_area *work_area)
 {
   work_area->allocated += 16 * sizeof (int);
-  if (work_area->table)
-    work_area->table
-      = (int *) realloc (work_area->table, work_area->allocated);
-  else
-    work_area->table
-      = (int *) malloc (work_area->allocated);
+  work_area->table = realloc (work_area->table, work_area->allocated);
 }
 
 #if 0
@@ -3741,16 +3734,8 @@
     if (fail_stack.size < re_max_failures * TYPICAL_FAILURE_SIZE)
       {
        fail_stack.size = re_max_failures * TYPICAL_FAILURE_SIZE;
-
-       if (! fail_stack.stack)
-         fail_stack.stack
-           = (fail_stack_elt_t *) malloc (fail_stack.size
-                                          * sizeof (fail_stack_elt_t));
-       else
-         fail_stack.stack
-           = (fail_stack_elt_t *) realloc (fail_stack.stack,
-                                           (fail_stack.size
-                                            * sizeof (fail_stack_elt_t)));
+       falk_stack.stack = realloc (fail_stack.stack,
+                                   fail_stack.size * sizeof *falk_stack.stack);
       }
 
     regex_grow_registers (num_regs);
@@ -6408,13 +6393,13 @@
 
   if (!re_comp_buf.buffer)
     {
-      re_comp_buf.buffer = (unsigned char *) malloc (200);
+      re_comp_buf.buffer = malloc (200);
       if (re_comp_buf.buffer == NULL)
        /* Yes, we're discarding `const' here if !HAVE_LIBINTL.  */
        return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
       re_comp_buf.allocated = 200;
 
-      re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
+      re_comp_buf.fastmap = malloc (1 << BYTEWIDTH);
       if (re_comp_buf.fastmap == NULL)
        /* Yes, we're discarding `const' here if !HAVE_LIBINTL.  */
        return (char *) gettext (re_error_msgid[(int) REG_ESPACE]);
@@ -6498,15 +6483,13 @@
   preg->used = 0;
 
   /* Try to allocate space for the fastmap.  */
-  preg->fastmap = (char *) malloc (1 << BYTEWIDTH);
+  preg->fastmap = malloc (1 << BYTEWIDTH);
 
   if (cflags & REG_ICASE)
     {
       unsigned i;
 
-      preg->translate
-       = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE
-                                     * sizeof (*(RE_TRANSLATE_TYPE)0));
+      preg->translate = malloc (CHAR_SET_SIZE * sizeof *preg->translate);
       if (preg->translate == NULL)
        return (int) REG_ESPACE;
 

=== modified file 'src/region-cache.c'
--- a/src/region-cache.c        2012-07-05 06:32:41 +0000
+++ b/src/region-cache.c        2012-07-05 18:35:48 +0000
@@ -132,7 +132,7 @@
 struct region_cache *
 new_region_cache (void)
 {
-  struct region_cache *c = xmalloc (sizeof (struct region_cache));
+  struct region_cache *c = xmalloc (sizeof *c);
 
   c->gap_start = 0;
   c->gap_len = NEW_CACHE_GAP;

=== modified file 'src/scroll.c'
--- a/src/scroll.c      2012-06-28 07:50:50 +0000
+++ b/src/scroll.c      2012-07-05 18:35:48 +0000
@@ -253,11 +253,11 @@
   /* A queue for line insertions to be done.  */
   struct queue { int count, pos; };
   struct queue *queue_start
-    = (struct queue *) alloca (current_matrix->nrows * sizeof (struct queue));
+    = alloca (current_matrix->nrows * sizeof *queue_start);
   struct queue *queue = queue_start;
 
-  char *retained_p = (char *) alloca (window_size * sizeof (char));
-  int *copy_from = (int *) alloca (window_size * sizeof (int));
+  char *retained_p = alloca (window_size * sizeof *retained_p);
+  int *copy_from = alloca (window_size * sizeof *copy_from);
 
   /* Zero means line is empty.  */
   memset (retained_p, 0, window_size * sizeof (char));
@@ -671,11 +671,11 @@
   int write_follows_p = 1;
 
   /* For each row in the new matrix what row of the old matrix it is.  */
-  int *copy_from = (int *) alloca (window_size * sizeof (int));
+  int *copy_from = alloca (window_size * sizeof *copy_from);
 
   /* Non-zero for each row in the new matrix that is retained from the
      old matrix.  Lines not retained are empty.  */
-  char *retained_p = (char *) alloca (window_size * sizeof (char));
+  char *retained_p = alloca (window_size * sizeof *retained_p);
 
   memset (retained_p, 0, window_size * sizeof (char));
 

=== modified file 'src/search.c'
--- a/src/search.c      2012-07-05 06:32:41 +0000
+++ b/src/search.c      2012-07-05 18:35:48 +0000
@@ -175,8 +175,7 @@
   for (cp = searchbuf_head; cp != 0; cp = cp->next)
     {
       cp->buf.allocated = cp->buf.used;
-      cp->buf.buffer
-       = (unsigned char *) xrealloc (cp->buf.buffer, cp->buf.used);
+      cp->buf.buffer = xrealloc (cp->buf.buffer, cp->buf.used);
     }
 }
 
@@ -1274,7 +1273,7 @@
          raw_pattern_size_byte
            = count_size_as_multibyte (SDATA (string),
                                       raw_pattern_size);
-         raw_pattern = (unsigned char *) alloca (raw_pattern_size_byte + 1);
+         raw_pattern = alloca (raw_pattern_size_byte + 1);
          copy_text (SDATA (string), raw_pattern,
                     SCHARS (string), 0, 1);
        }
@@ -1288,7 +1287,7 @@
             the chosen single-byte character set can possibly match.  */
          raw_pattern_size = SCHARS (string);
          raw_pattern_size_byte = SCHARS (string);
-         raw_pattern = (unsigned char *) alloca (raw_pattern_size + 1);
+         raw_pattern = alloca (raw_pattern_size + 1);
          copy_text (SDATA (string), raw_pattern,
                     SBYTES (string), 1, 0);
        }
@@ -1296,7 +1295,7 @@
       /* Copy and optionally translate the pattern.  */
       len = raw_pattern_size;
       len_byte = raw_pattern_size_byte;
-      patbuf = (unsigned char *) alloca (len * MAX_MULTIBYTE_LENGTH);
+      patbuf = alloca (len * MAX_MULTIBYTE_LENGTH);
       pat = patbuf;
       base_pat = raw_pattern;
       if (multibyte)
@@ -2741,8 +2740,7 @@
 
   prev = Qnil;
 
-  data = (Lisp_Object *) alloca ((2 * search_regs.num_regs + 1)
-                                * sizeof (Lisp_Object));
+  data = alloca ((2 * search_regs.num_regs + 1) * sizeof *data);
 
   len = 0;
   for (i = 0; i < search_regs.num_regs; i++)
@@ -3008,7 +3006,7 @@
 
   CHECK_STRING (string);
 
-  temp = (char *) alloca (SBYTES (string) * 2);
+  temp = alloca (SBYTES (string) * 2);
 
   /* Now copy the data into the new string, inserting escapes. */
 

=== modified file 'src/sound.c'
--- a/src/sound.c       2012-07-05 06:32:41 +0000
+++ b/src/sound.c       2012-07-05 18:35:48 +0000
@@ -594,7 +594,7 @@
       ptrdiff_t blksize = sd->period_size ? sd->period_size (sd) : 2048;
       ptrdiff_t data_left = header->data_length;
 
-      buffer = (char *) alloca (blksize);
+      buffer = alloca (blksize);
       lseek (s->fd, sizeof *header, SEEK_SET);
       while (data_left > 0
              && (nbytes = emacs_read (s->fd, buffer, blksize)) > 0)
@@ -688,7 +688,7 @@
       lseek (s->fd, header->data_offset, SEEK_SET);
 
       /* Copy sound data to the device.  */
-      buffer = (char *) alloca (blksize);
+      buffer = alloca (blksize);
       while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0)
        sd->write (sd, buffer, nbytes);
 
@@ -932,7 +932,7 @@
   else
     file = DEFAULT_ALSA_SOUND_DEVICE;
 
-  p = xmalloc (sizeof (*p));
+  p = xmalloc (sizeof *p);
   p->handle = NULL;
   p->hwparams = NULL;
   p->swparams = NULL;
@@ -1364,10 +1364,10 @@
 #ifndef WINDOWSNT
   file = Qnil;
   GCPRO2 (sound, file);
-  current_sound_device = xzalloc (sizeof (struct sound_device));
-  current_sound = xzalloc (sizeof (struct sound));
+  current_sound_device = xzalloc (sizeof *current_sound_device);
+  current_sound = xzalloc (sizeof *current_sound);
   record_unwind_protect (sound_cleanup, Qnil);
-  current_sound->header = (char *) alloca (MAX_SOUND_HEADER_BYTES);
+  current_sound->header = alloca (MAX_SOUND_HEADER_BYTES);
 
   if (STRINGP (attrs[SOUND_FILE]))
     {
@@ -1399,7 +1399,7 @@
   if (STRINGP (attrs[SOUND_DEVICE]))
     {
       int len = SCHARS (attrs[SOUND_DEVICE]);
-      current_sound_device->file = (char *) alloca (len + 1);
+      current_sound_device->file = alloca (len + 1);
       strcpy (current_sound_device->file, SSDATA (attrs[SOUND_DEVICE]));
     }
 
@@ -1431,7 +1431,7 @@
 
   lo_file = Fexpand_file_name (attrs[SOUND_FILE], Qnil);
   len = XSTRING (lo_file)->size;
-  psz_file = (char *) alloca (len + 1);
+  psz_file = alloca (len + 1);
   strcpy (psz_file, XSTRING (lo_file)->data);
   if (INTEGERP (attrs[SOUND_VOLUME]))
     {

=== modified file 'src/syntax.c'
--- a/src/syntax.c      2012-07-03 18:24:42 +0000
+++ b/src/syntax.c      2012-07-05 18:35:48 +0000
@@ -1581,7 +1581,7 @@
          fastmap[CHAR_LEADING_CODE (c)] = 1;
          range_start_byte = i;
          range_start_char = c;
-         char_ranges = (int *) alloca (sizeof (int) * 128 * 2);
+         char_ranges = alloca (sizeof *char_ranges * 128 * 2);
          for (i = 129; i < 0400; i++)
            {
              c = BYTE8_TO_CHAR (i);
@@ -1602,7 +1602,7 @@
     }
   else                         /* STRING is multibyte */
     {
-      char_ranges = (int *) alloca (sizeof (int) * SCHARS (string) * 2);
+      char_ranges = alloca (sizeof *char_ranges * SCHARS (string) * 2);
 
       while (i_byte < size_byte)
        {

=== modified file 'src/sysdep.c'
--- a/src/sysdep.c      2012-07-05 06:32:41 +0000
+++ b/src/sysdep.c      2012-07-05 18:35:48 +0000
@@ -143,7 +143,7 @@
 #endif
       )
     {
-      buf = (char *) malloc (strlen (pwd) + 1);
+      buf = malloc (strlen (pwd) + 1);
       if (!buf)
         return NULL;
       strcpy (buf, pwd);
@@ -152,7 +152,7 @@
   else
     {
       size_t buf_size = 1024;
-      buf = (char *) malloc (buf_size);
+      buf = malloc (buf_size);
       if (!buf)
         return NULL;
       for (;;)
@@ -167,7 +167,7 @@
               return NULL;
             }
           buf_size *= 2;
-          buf = (char *) realloc (buf, buf_size);
+          buf = realloc (buf, buf_size);
           if (!buf)
             return NULL;
         }
@@ -176,7 +176,7 @@
   else
     {
       /* We need MAXPATHLEN here.  */
-      buf = (char *) malloc (MAXPATHLEN + 1);
+      buf = malloc (MAXPATHLEN + 1);
       if (!buf)
         return NULL;
       if (getwd (buf) == NULL)
@@ -516,7 +516,7 @@
     goto xyzzy;
 
   dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil);
-  str_volatile = str = (unsigned char *) alloca (SCHARS (dir) + 2);
+  str_volatile = str = alloca (SCHARS (dir) + 2);
   len = SCHARS (dir);
   memcpy (str, SDATA (dir), len);
   if (str[len - 1] != '/') str[len++] = '/';
@@ -851,7 +851,7 @@
     return;                     /* The tty is suspended. */
 
   if (! tty_out->old_tty)
-    tty_out->old_tty = xmalloc (sizeof (struct emacs_tty));
+    tty_out->old_tty = xmalloc (sizeof *tty_out->old_tty);
 
   emacs_get_tty (fileno (tty_out->input), tty_out->old_tty);
 
@@ -1345,7 +1345,7 @@
   Vsystem_name = build_string (uts.nodename);
 #else /* HAVE_GETHOSTNAME */
   unsigned int hostname_size = 256;
-  char *hostname = (char *) alloca (hostname_size);
+  char *hostname = alloca (hostname_size);
 
   /* Try to get the host name; if the buffer is too short, try
      again.  Apparently, the only indication gethostname gives of
@@ -1361,7 +1361,7 @@
        break;
 
       hostname_size <<= 1;
-      hostname = (char *) alloca (hostname_size);
+      hostname = alloca (hostname_size);
     }
 #ifdef HAVE_SOCKETS
   /* Turn the hostname into the official, fully-qualified hostname.

=== modified file 'src/term.c'
--- a/src/term.c        2012-07-05 06:32:41 +0000
+++ b/src/term.c        2012-07-05 18:35:48 +0000
@@ -2858,13 +2858,11 @@
 void
 create_tty_output (struct frame *f)
 {
-  struct tty_output *t;
+  struct tty_output *t = xzalloc (sizeof *t);
 
   if (! FRAME_TERMCAP_P (f))
     abort ();
 
-  t = xzalloc (sizeof (struct tty_output));
-
   t->display_info = FRAME_TERMINAL (f)->display_info.tty;
 
   f->output_data.tty = t;
@@ -3064,7 +3062,7 @@
   been_here = 1;
   tty = &the_only_display_info;
 #else
-  tty = xzalloc (sizeof (struct tty_display_info));
+  tty = xzalloc (sizeof *tty);
 #endif
   tty->next = tty_list;
   tty_list = tty;
@@ -3073,7 +3071,7 @@
   terminal->display_info.tty = tty;
   tty->terminal = terminal;
 
-  tty->Wcm = xmalloc (sizeof (struct cm));
+  tty->Wcm = xmalloc (sizeof *tty->Wcm);
   Wcm_clear (tty);
 
   encode_terminal_src_size = 0;
@@ -3343,7 +3341,7 @@
   tty->mouse_highlight.mouse_face_window = Qnil;
 #endif
 
-  terminal->kboard = xmalloc (sizeof (KBOARD));
+  terminal->kboard = xmalloc (sizeof *terminal->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-07-05 06:32:41 +0000
+++ b/src/termcap.c     2012-07-05 18:35:48 +0000
@@ -478,7 +478,7 @@
        {
          ptrdiff_t offset1 = bp1 - bp, offset2 = tc_search_point - bp;
          malloc_size = offset1 + buf.size;
-         bp = termcap_name = (char *) xrealloc (bp, malloc_size);
+         bp = termcap_name = xrealloc (bp, malloc_size);
          bp1 = termcap_name + offset1;
          tc_search_point = termcap_name + offset2;
        }
@@ -504,7 +504,7 @@
   xfree (buf.beg);
 
   if (malloc_size)
-    bp = (char *) xrealloc (bp, bp1 - bp + 1);
+    bp = xrealloc (bp, bp1 - bp + 1);
 
  ret:
   term_entry = bp;

=== modified file 'src/unexmacosx.c'
--- a/src/unexmacosx.c  2012-06-27 03:52:02 +0000
+++ b/src/unexmacosx.c  2012-07-05 18:35:48 +0000
@@ -394,7 +394,7 @@
        }
       else
        {
-         r = (struct region_t *) malloc (sizeof (struct region_t));
+         r = malloc (sizeof *r);
 
          if (!r)
            unexec_error ("cannot allocate region structure");
@@ -669,7 +669,7 @@
 #endif
 
   nlc = mh.ncmds;
-  lca = (struct load_command **) malloc (nlc * sizeof (struct load_command *));
+  lca = malloc (nlc * sizeof *lca);
 
   for (i = 0; i < nlc; i++)
     {
@@ -678,7 +678,7 @@
         size first and then read the rest.  */
       if (!unexec_read (&lc, sizeof (struct load_command)))
         unexec_error ("cannot read load command");
-      lca[i] = (struct load_command *) malloc (lc.cmdsize);
+      lca[i] = malloc (lc.cmdsize);
       memcpy (lca[i], &lc, sizeof (struct load_command));
       if (!unexec_read (lca[i] + 1, lc.cmdsize - sizeof (struct load_command)))
         unexec_error ("cannot read content of load command");
@@ -1378,7 +1378,7 @@
          size_t old_size = ((unexec_malloc_header_t *) old_ptr)[-1].u.size;
          size_t size = new_size > old_size ? old_size : new_size;
 
-         p = (size_t *) malloc (new_size);
+         p = malloc (new_size);
          if (size)
            memcpy (p, old_ptr, size);
        }

=== modified file 'src/window.c'
--- a/src/window.c      2012-07-04 17:58:55 +0000
+++ b/src/window.c      2012-07-05 18:35:48 +0000
@@ -5469,9 +5469,8 @@
         really like to do is to free only those matrices not reused
         below.  */
       root_window = XWINDOW (FRAME_ROOT_WINDOW (f));
-      leaf_windows
-       = (struct window **) alloca (count_windows (root_window)
-                                    * sizeof (struct window *));
+      leaf_windows = alloca (count_windows (root_window)
+                            * sizeof *leaf_windows);
       n_leaf_windows = get_leaf_windows (root_window, leaf_windows, 0);
 
       /* Kludge Alert!

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2012-07-05 16:28:34 +0000
+++ b/src/xdisp.c       2012-07-05 18:35:48 +0000
@@ -5400,8 +5400,7 @@
   ptrdiff_t size = 20;
   ptrdiff_t n = 0, i, j;
   int invis_p;
-  struct overlay_entry *entries
-    = (struct overlay_entry *) alloca (size * sizeof *entries);
+  struct overlay_entry *entries = alloca (size * sizeof *entries);
   USE_SAFE_ALLOCA;
 
   if (charpos <= 0)
@@ -14949,7 +14948,7 @@
     return rc;
 #endif
 
-  /* Previously, there was a check for Lisp integer in the 
+  /* Previously, there was a check for Lisp integer in the
      if-statement below. Now, this field is converted to
      ptrdiff_t, thus zero means invalid position in a buffer.  */
   eassert (w->last_point > 0);
@@ -18012,7 +18011,7 @@
 
       for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area)
        {
-         char *s = (char *) alloca (row->used[area] + 1);
+         char *s = alloca (row->used[area] + 1);
          int i;
 
          for (i = 0; i < row->used[area]; ++i)
@@ -21137,7 +21136,7 @@
        }
       else if (CHARACTERP (eoltype))
        {
-         unsigned char *tmp = (unsigned char *) alloca (MAX_MULTIBYTE_LENGTH);
+         unsigned char *tmp = alloca (MAX_MULTIBYTE_LENGTH);
          int c = XFASTINT (eoltype);
          eol_str_len = CHAR_STRING (c, tmp);
          eol_str = tmp;
@@ -23010,7 +23009,7 @@
 #define BUILD_STRETCH_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X)   \
      do                                                                        
    \
        {                                                                   \
-        s = (struct glyph_string *) alloca (sizeof *s);                    \
+        s = alloca (sizeof *s);                                            \
         INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL);              \
         START = fill_stretch_glyph_string (s, START, END);                 \
         append_glyph_string (&HEAD, &TAIL, s);                             \
@@ -23030,7 +23029,7 @@
 #define BUILD_IMAGE_GLYPH_STRING(START, END, HEAD, TAIL, HL, X, LAST_X) \
      do                                                                        
\
        {                                                               \
-        s = (struct glyph_string *) alloca (sizeof *s);                \
+        s = alloca (sizeof *s);                                        \
         INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL);          \
         fill_image_glyph_string (s);                                   \
         append_glyph_string (&HEAD, &TAIL, s);                         \
@@ -23057,8 +23056,8 @@
                                                                           \
         face_id = (row)->glyphs[area][START].face_id;                     \
                                                                           \
-        s = (struct glyph_string *) alloca (sizeof *s);                   \
-        char2b = (XChar2b *) alloca ((END - START) * sizeof *char2b);     \
+        s = alloca (sizeof *s);                                           \
+        char2b = alloca ((END - START) * sizeof *char2b);                 \
         INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL);           \
         append_glyph_string (&HEAD, &TAIL, s);                            \
         s->x = (X);                                                       \
@@ -23086,13 +23085,13 @@
     struct glyph_string *first_s = NULL;                                   \
     int n;                                                                 \
                                                                            \
-    char2b = (XChar2b *) alloca ((sizeof *char2b) * cmp->glyph_len);       \
+    char2b = alloca (cmp->glyph_len * sizeof *char2b);                     \
                                                                            \
     /* Make glyph_strings for each glyph sequence that is drawable by      \
        the same face, and append them to HEAD/TAIL.  */                        
    \
     for (n = 0; n < cmp->glyph_len;)                                       \
       {                                                                        
    \
-       s = (struct glyph_string *) alloca (sizeof *s);                     \
+       s = alloca (sizeof *s);                                             \
        INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL);             \
        append_glyph_string (&(HEAD), &(TAIL), s);                          \
        s->cmp = cmp;                                                       \
@@ -23120,9 +23119,8 @@
     face_id = (row)->glyphs[area][START].face_id;                        \
     gstring = (composition_gstring_from_id                               \
               ((row)->glyphs[area][START].u.cmp.id));                    \
-    s = (struct glyph_string *) alloca (sizeof *s);                      \
-    char2b = (XChar2b *) alloca ((sizeof *char2b)                        \
-                                * LGSTRING_GLYPH_LEN (gstring));         \
+    s = alloca (sizeof *s);                                              \
+    char2b = alloca (LGSTRING_GLYPH_LEN (gstring) * sizeof *char2b);     \
     INIT_GLYPH_STRING (s, char2b, w, row, area, START, HL);              \
     append_glyph_string (&(HEAD), &(TAIL), s);                           \
     s->x = (X);                                                                
  \
@@ -23141,7 +23139,7 @@
                                                                            \
       face_id = (row)->glyphs[area][START].face_id;                        \
                                                                            \
-      s = (struct glyph_string *) alloca (sizeof *s);                      \
+      s = alloca (sizeof *s);                                              \
       INIT_GLYPH_STRING (s, NULL, w, row, area, START, HL);                \
       append_glyph_string (&HEAD, &TAIL, s);                               \
       s->x = (X);                                                          \

=== modified file 'src/xfaces.c'
--- a/src/xfaces.c      2012-07-05 06:32:41 +0000
+++ b/src/xfaces.c      2012-07-05 18:35:48 +0000
@@ -703,9 +703,8 @@
             unsigned long mask,
             XGCValues *xgcv)
 {
-  GC gc = xmalloc (sizeof (*gc));
-  if (gc)
-    memcpy (gc, xgcv, sizeof (XGCValues));
+  GC gc = xmalloc (sizeof *gc);
+  memcpy (gc, xgcv, sizeof (XGCValues));
   return gc;
 }
 
@@ -2951,7 +2950,7 @@
   else if (EQ (attr, QCunderline))
     {
       int valid_p = 0;
-      
+
       if (UNSPECIFIEDP (value) || IGNORE_DEFFACE_P (value))
        valid_p = 1;
       else if (NILP (value) || EQ (value, Qt))
@@ -2971,8 +2970,8 @@
               list = CDR_SAFE (list);
               val = CAR_SAFE (list);
               list = CDR_SAFE (list);
-            
-              if(NILP (key) || NILP (val)) 
+
+              if (NILP (key) || NILP (val))
                 {
                   valid_p = 0;
                   break;
@@ -2985,8 +2984,8 @@
                   valid_p = 0;
                   break;
                 }
-              
-              else if (EQ (key, QCstyle) 
+
+              else if (EQ (key, QCstyle)
                        && !(EQ (val, Qline) || EQ (val, Qwave)))
                 {
                   valid_p = 0;
@@ -2994,10 +2993,10 @@
                 }
             }
         }
-      
+
       if (!valid_p)
         signal_error ("Invalid face underline", value);
-      
+
       old_value = LFACE_UNDERLINE (lface);
       LFACE_UNDERLINE (lface) = value;
     }
@@ -5774,7 +5773,7 @@
     }
   else if (CONSP (underline))
     {
-      /* `(:color COLOR :style STYLE)'.  
+      /* `(:color COLOR :style STYLE)'.
          STYLE being one of `line' or `wave'. */
       face->underline_p = 1;
       face->underline_color = 0;
@@ -5816,7 +5815,7 @@
             }
         }
     }
-  
+
   overline = attrs[LFACE_OVERLINE_INDEX];
   if (STRINGP (overline))
     {

=== modified file 'src/xfns.c'
--- a/src/xfns.c        2012-07-05 06:32:41 +0000
+++ b/src/xfns.c        2012-07-05 18:35:48 +0000
@@ -1881,7 +1881,7 @@
 
   /* Make a fontset name from the base font name.  */
   if (xic_default_fontset == base_fontname)
-    { 
+    {
       /* There is no base font name, use the default.  */
       fontsetname = xmalloc (strlen (base_fontname) + 2);
       strcpy (fontsetname, base_fontname);
@@ -1953,21 +1953,21 @@
 
          /* Build the font spec that matches all charsets.  */
          len = p - base_fontname + strlen (allcs) + 1;
-         font_allcs = (char *) alloca (len);
+         font_allcs = alloca (len);
          memcpy (font_allcs, base_fontname, p - base_fontname);
          strcat (font_allcs, allcs);
 
          /* Build the font spec that matches all families and
             add-styles.  */
          len = p - p1 + strlen (allcs) + strlen (allfamilies) + 1;
-         font_allfamilies = (char *) alloca (len);
+         font_allfamilies = alloca (len);
          strcpy (font_allfamilies, allfamilies);
          memcpy (font_allfamilies + strlen (allfamilies), p1, p - p1);
          strcat (font_allfamilies, allcs);
 
          /* Build the font spec that matches all.  */
          len = p - p2 + strlen (allcs) + strlen (all) + strlen (allfamilies) + 
1;
-         font_all = (char *) alloca (len);
+         font_all = alloca (len);
          strcpy (font_all, allfamilies);
          strcat (font_all, all);
          memcpy (font_all + strlen (all) + strlen (allfamilies), p2, p - p2);
@@ -3129,7 +3129,7 @@
   f->terminal = dpyinfo->terminal;
 
   f->output_method = output_x_window;
-  f->output_data.x = xzalloc (sizeof (struct x_output));
+  f->output_data.x = xzalloc (sizeof *f->output_data.x);
   f->output_data.x->icon_bitmap = -1;
   FRAME_FONTSET (f) = -1;
   f->output_data.x->scroll_bar_foreground_pixel = -1;
@@ -3957,7 +3957,7 @@
       /* VALUE should be of the form CLASS-DEPTH, where CLASS is one
         of `PseudoColor', `TrueColor' etc. and DEPTH is the color
         depth, a decimal number.  NAME is compared with case ignored.  */
-      char *s = (char *) alloca (SBYTES (value) + 1);
+      char *s = alloca (SBYTES (value) + 1);
       char *dash;
       int i, class = -1;
       XVisualInfo vinfo;
@@ -4614,7 +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 = xzalloc (sizeof (struct x_output));
+  f->output_data.x = xzalloc (sizeof *f->output_data.x);
   f->output_data.x->icon_bitmap = -1;
   FRAME_FONTSET (f) = -1;
   f->output_data.x->scroll_bar_foreground_pixel = -1;

=== modified file 'src/xftfont.c'
--- a/src/xftfont.c     2012-01-19 07:21:25 +0000
+++ b/src/xftfont.c     2012-07-05 18:35:48 +0000
@@ -527,7 +527,7 @@
     }
 #endif
 
-  xftface_info = malloc (sizeof (struct xftface_info));
+  xftface_info = malloc (sizeof *xftface_info);
   if (! xftface_info)
     return -1;
   xftfont_get_colors (f, face, face->gc, NULL,

=== modified file 'src/xgselect.c'
--- a/src/xgselect.c    2012-06-22 21:17:42 +0000
+++ b/src/xgselect.c    2012-07-05 18:35:48 +0000
@@ -153,6 +153,6 @@
 {
 #if defined (USE_GTK) || defined (HAVE_GCONF) || defined (HAVE_GSETTINGS)
   gfds_size = 128;
-  gfds = xmalloc (sizeof (*gfds)*gfds_size);
+  gfds = xmalloc (gfds_size * sizeof *gfds);
 #endif
 }

=== modified file 'src/xmenu.c'
--- a/src/xmenu.c       2012-07-05 06:32:41 +0000
+++ b/src/xmenu.c       2012-07-05 18:35:48 +0000
@@ -980,8 +980,7 @@
       ptrdiff_t specpdl_count = SPECPDL_INDEX ();
       int previous_menu_items_used = f->menu_bar_items_used;
       Lisp_Object *previous_items
-       = (Lisp_Object *) alloca (previous_menu_items_used
-                                 * sizeof (Lisp_Object));
+       = alloca (previous_menu_items_used * sizeof *previous_items);
       int subitems;
 
       /* If we are making a new widget, its contents are empty,
@@ -1028,10 +1027,11 @@
       menu_items = f->menu_bar_vector;
       menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
       subitems = ASIZE (items) / 4;
-      submenu_start = (int *) alloca ((subitems + 1) * sizeof (int));
-      submenu_end = (int *) alloca (subitems * sizeof (int));
-      submenu_n_panes = (int *) alloca (subitems * sizeof (int));
-      submenu_top_level_items = (int *) alloca (subitems * sizeof (int));
+      submenu_start = alloca ((subitems + 1) * sizeof *submenu_start);
+      submenu_end = alloca (subitems * sizeof *submenu_end);
+      submenu_n_panes = alloca (subitems * sizeof *submenu_n_panes);
+      submenu_top_level_items = alloca (subitems
+                                       * sizeof *submenu_top_level_items);
       init_menu_items ();
       for (i = 0; i < subitems; i++)
        {
@@ -1639,9 +1639,9 @@
   int i;
   widget_value *wv, *save_wv = 0, *first_wv = 0, *prev_wv = 0;
   widget_value **submenu_stack
-    = (widget_value **) alloca (menu_items_used * sizeof (widget_value *));
+    = alloca (menu_items_used * sizeof *submenu_stack);
   Lisp_Object *subprefix_stack
-    = (Lisp_Object *) alloca (menu_items_used * sizeof (Lisp_Object));
+    = alloca (menu_items_used * sizeof *subprefix_stack);
   int submenu_depth = 0;
 
   int first_pane;
@@ -2416,7 +2416,7 @@
            {
              /* if alloca is fast, use that to make the space,
                 to reduce gc needs.  */
-             item_data = (char *) alloca (maxwidth + SBYTES (descrip) + 1);
+             item_data = alloca (maxwidth + SBYTES (descrip) + 1);
              memcpy (item_data, SSDATA (item_name), SBYTES (item_name));
              for (j = SCHARS (item_name); j < maxwidth; j++)
                item_data[j] = ' ';

=== modified file 'src/xrdb.c'
--- a/src/xrdb.c        2012-07-05 06:32:41 +0000
+++ b/src/xrdb.c        2012-07-05 18:35:48 +0000
@@ -74,10 +74,8 @@
 x_get_customization_string (XrmDatabase db, const char *name,
                            const char *class)
 {
-  char *full_name
-    = (char *) alloca (strlen (name) + sizeof ("customization") + 3);
-  char *full_class
-    = (char *) alloca (strlen (class) + sizeof ("Customization") + 3);
+  char *full_name = alloca (strlen (name) + sizeof "customization" + 3);
+  char *full_class = alloca (strlen (class) + sizeof "Customization" + 3);
   char *result;
 
   sprintf (full_name,  "%s.%s", name,  "customization");
@@ -206,7 +204,7 @@
          if (min (PTRDIFF_MAX, SIZE_MAX) / 2 - 1 - path_len < next_len)
            memory_full (SIZE_MAX);
          path_size = (path_len + next_len + 1) * 2;
-         path = (char *) xrealloc (path, path_size);
+         path = xrealloc (path, path_size);
        }
 
       memcpy (path + path_len, next, next_len);
@@ -400,7 +398,7 @@
       char *xdefault;
 
       home = gethomedir ();
-      xdefault = xmalloc (strlen (home) + sizeof (".Xdefaults"));
+      xdefault = xmalloc (strlen (home) + sizeof ".Xdefaults");
       strcpy (xdefault, home);
       strcat (xdefault, ".Xdefaults");
       db = XrmGetFileDatabase (xdefault);
@@ -434,7 +432,7 @@
       char *home = gethomedir ();
       char const *host = get_system_name ();
       ptrdiff_t pathsize = strlen (home) + sizeof xdefaults + strlen (host);
-      path = (char *) xrealloc (home, pathsize);
+      path = xrealloc (home, pathsize);
       strcat (strcat (path, xdefaults), host);
       p = path;
     }

=== modified file 'src/xselect.c'
--- a/src/xselect.c     2012-07-05 06:32:41 +0000
+++ b/src/xselect.c     2012-07-05 18:35:48 +0000
@@ -180,7 +180,7 @@
        }
     }
 
-  queue_tmp = xmalloc (sizeof (struct selection_event_queue));
+  queue_tmp = xmalloc (sizeof *queue_tmp);
   TRACE1 ("QUEUE SELECTION EVENT %p", queue_tmp);
   queue_tmp->event = *event;
   queue_tmp->next = selection_queue;
@@ -907,7 +907,7 @@
     {
       if (for_multiple)
        {
-         cs = xmalloc (sizeof (struct selection_data));
+         cs = xmalloc (sizeof *cs);
          cs->data = (unsigned char *) &conversion_fail_tag;
          cs->size = 1;
          cs->format = 32;
@@ -924,7 +924,7 @@
     }
 
   /* Otherwise, record the converted selection to binary.  */
-  cs = xmalloc (sizeof (struct selection_data));
+  cs = xmalloc (sizeof *cs);
   cs->data = NULL;
   cs->nofree = 1;
   cs->property = property;
@@ -1775,20 +1775,24 @@
     }
   else if (SYMBOLP (obj))
     {
-      *data_ret = xmalloc (sizeof (Atom) + 1);
+      void *data = xmalloc (sizeof (Atom) + 1);
+      Atom *x_atom_ptr = data;
+      *data_ret = data;
       *format_ret = 32;
       *size_ret = 1;
       (*data_ret) [sizeof (Atom)] = 0;
-      (*(Atom **) data_ret) [0] = symbol_to_x_atom (dpyinfo, obj);
+      *x_atom_ptr = symbol_to_x_atom (dpyinfo, obj);
       if (NILP (type)) type = QATOM;
     }
   else if (RANGED_INTEGERP (X_SHRT_MIN, obj, X_SHRT_MAX))
     {
-      *data_ret = xmalloc (sizeof (short) + 1);
+      void *data = xmalloc (sizeof (short) + 1);
+      short *short_ptr = data;
+      *data_ret = data;
       *format_ret = 16;
       *size_ret = 1;
       (*data_ret) [sizeof (short)] = 0;
-      (*(short **) data_ret) [0] = XINT (obj);
+      *short_ptr = XINT (obj);
       if (NILP (type)) type = QINTEGER;
     }
   else if (INTEGERP (obj)
@@ -1797,11 +1801,13 @@
                   || (CONSP (XCDR (obj))
                       && INTEGERP (XCAR (XCDR (obj)))))))
     {
-      *data_ret = xmalloc (sizeof (unsigned long) + 1);
+      void *data = xmalloc (sizeof (unsigned long) + 1);
+      unsigned long *x_long_ptr = data;
+      *data_ret = data;
       *format_ret = 32;
       *size_ret = 1;
       (*data_ret) [sizeof (unsigned long)] = 0;
-      (*(unsigned long **) data_ret) [0] = cons_to_x_long (obj);
+      *x_long_ptr = cons_to_x_long (obj);
       if (NILP (type)) type = QINTEGER;
     }
   else if (VECTORP (obj))
@@ -1816,23 +1822,28 @@
       if (SYMBOLP (AREF (obj, 0)))
        /* This vector is an ATOM set */
        {
+         void *data;
+         Atom *x_atoms;
          if (NILP (type)) type = QATOM;
          for (i = 0; i < size; i++)
            if (!SYMBOLP (AREF (obj, i)))
              signal_error ("All elements of selection vector must have same 
type", obj);
 
-         *data_ret = xnmalloc (size, sizeof (Atom));
+         *data_ret = data = xnmalloc (size, sizeof *x_atoms);
+         x_atoms = data;
          *format_ret = 32;
          *size_ret = size;
          for (i = 0; i < size; i++)
-           (*(Atom **) data_ret) [i]
-             = symbol_to_x_atom (dpyinfo, AREF (obj, i));
+           x_atoms[i] = symbol_to_x_atom (dpyinfo, AREF (obj, i));
        }
       else
        /* This vector is an INTEGER set, or something like it */
        {
          int format = 16;
          int data_size = sizeof (short);
+         void *data;
+         unsigned long *x_atoms;
+         short *shorts;
          if (NILP (type)) type = QINTEGER;
          for (i = 0; i < size; i++)
            {
@@ -1847,17 +1858,17 @@
                  break;
                }
            }
-         *data_ret = xnmalloc (size, data_size);
+         *data_ret = data = xnmalloc (size, data_size);
+         x_atoms = data;
+         shorts = data;
          *format_ret = format;
          *size_ret = size;
          for (i = 0; i < size; i++)
            {
              if (format == 32)
-               (*((unsigned long **) data_ret)) [i] =
-                 cons_to_x_long (AREF (obj, i));
+               x_atoms[i] = cons_to_x_long (AREF (obj, i));
              else
-               (*((short **) data_ret)) [i] =
-                 XINT (AREF (obj, i));
+               shorts[i] = XINT (AREF (obj, i));
            }
        }
     }

=== modified file 'src/xterm.c'
--- a/src/xterm.c       2012-07-05 06:32:41 +0000
+++ b/src/xterm.c       2012-07-05 18:35:48 +0000
@@ -6450,7 +6450,7 @@
               if (status_return == XBufferOverflow)
                 {
                   copy_bufsiz = nbytes + 1;
-                  copy_bufptr = (unsigned char *) alloca (copy_bufsiz);
+                  copy_bufptr = alloca (copy_bufsiz);
                   nbytes = XmbLookupString (FRAME_XIC (f),
                                             &event.xkey, (char *) copy_bufptr,
                                             copy_bufsiz, &keysym,
@@ -7670,7 +7670,7 @@
 void
 x_catch_errors (Display *dpy)
 {
-  struct x_error_message_stack *data = xmalloc (sizeof (*data));
+  struct x_error_message_stack *data = xmalloc (sizeof *data);
 
   /* Make sure any errors from previous requests have been dealt with.  */
   XSync (dpy, False);
@@ -7798,7 +7798,7 @@
   Lisp_Object frame, tail;
   ptrdiff_t idx = SPECPDL_INDEX ();
 
-  error_msg = (char *) alloca (strlen (error_message) + 1);
+  error_msg = alloca (strlen (error_message) + 1);
   strcpy (error_msg, error_message);
   handling_signal = 0;
 
@@ -8187,10 +8187,9 @@
   if (use_xim)
     {
 #ifdef HAVE_X11R6_XIM
-      struct xim_inst_t *xim_inst;
+      struct xim_inst_t *xim_inst = xmalloc (sizeof *xim_inst);
       ptrdiff_t len;
 
-      xim_inst = xmalloc (sizeof (struct xim_inst_t));
       dpyinfo->xim_callback_data = xim_inst;
       xim_inst->dpyinfo = dpyinfo;
       len = strlen (resource_name);
@@ -10098,7 +10097,7 @@
 
   /* We have definitely succeeded.  Record the new connection.  */
 
-  dpyinfo = xzalloc (sizeof (struct x_display_info));
+  dpyinfo = xzalloc (sizeof *dpyinfo);
   hlinfo = &dpyinfo->mouse_highlight;
 
   terminal = x_create_terminal (dpyinfo);
@@ -10116,7 +10115,7 @@
       terminal->kboard = share->terminal->kboard;
     else
       {
-       terminal->kboard = xmalloc (sizeof (KBOARD));
+       terminal->kboard = xmalloc (sizeof *terminal->kboard);
        init_kboard (terminal->kboard);
        KVAR (terminal->kboard, Vwindow_system) = Qx;
 
@@ -10370,8 +10369,8 @@
     const int atom_count = sizeof (atom_refs) / sizeof (atom_refs[0]);
     /* 1 for _XSETTINGS_SN  */
     const int total_atom_count = 1 + atom_count;
-    Atom *atoms_return = xmalloc (sizeof (Atom) * total_atom_count);
-    char **atom_names = xmalloc (sizeof (char *) * total_atom_count);
+    Atom *atoms_return = xmalloc (total_atom_count * sizeof *atoms_return);
+    char **atom_names = xmalloc (total_atom_count * sizeof *atom_names);
     static char const xsettings_fmt[] = "_XSETTINGS_S%d";
     char xsettings_atom_name[sizeof xsettings_fmt - 2
                             + INT_STRLEN_BOUND (int)];
@@ -10399,7 +10398,7 @@
 
   dpyinfo->x_dnd_atoms_size = 8;
   dpyinfo->x_dnd_atoms_length = 0;
-  dpyinfo->x_dnd_atoms = xmalloc (sizeof (*dpyinfo->x_dnd_atoms)
+  dpyinfo->x_dnd_atoms = xmalloc (sizeof *dpyinfo->x_dnd_atoms
                                   * dpyinfo->x_dnd_atoms_size);
 
   dpyinfo->net_supported_atoms = NULL;


reply via email to

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