Merge from trunk
[bpt/emacs.git] / src / alloc.c
index a23c688..7c8081f 100644 (file)
@@ -23,10 +23,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <limits.h>            /* For CHAR_BIT.  */
 #include <setjmp.h>
 
-#ifdef STDC_HEADERS
-#include <stddef.h>            /* For offsetof, used by PSEUDOVECSIZE. */
-#endif
-
 #ifdef ALLOC_DEBUG
 #undef INLINE
 #endif
@@ -298,7 +294,7 @@ static EMACS_INT pure_bytes_used_non_lisp;
 /* If nonzero, this is a warning delivered by malloc and not yet
    displayed.  */
 
-char *pending_malloc_warning;
+const char *pending_malloc_warning;
 
 /* Pre-computed signal argument for use when memory is exhausted.  */
 
@@ -329,23 +325,23 @@ Lisp_Object Vpost_gc_hook, Qpost_gc_hook;
 Lisp_Object Vgc_elapsed;       /* accumulated elapsed time in GC  */
 EMACS_INT gcs_done;            /* accumulated GCs  */
 
-static void mark_buffer P_ ((Lisp_Object));
-static void mark_terminals P_ ((void));
-extern void mark_kboards P_ ((void));
-extern void mark_ttys P_ ((void));
-extern void mark_backtrace P_ ((void));
-static void gc_sweep P_ ((void));
-static void mark_glyph_matrix P_ ((struct glyph_matrix *));
-static void mark_face_cache P_ ((struct face_cache *));
+static void mark_buffer (Lisp_Object);
+static void mark_terminals (void);
+extern void mark_kboards (void);
+extern void mark_ttys (void);
+extern void mark_backtrace (void);
+static void gc_sweep (void);
+static void mark_glyph_matrix (struct glyph_matrix *);
+static void mark_face_cache (struct face_cache *);
 
 #ifdef HAVE_WINDOW_SYSTEM
-extern void mark_fringe_data P_ ((void));
+extern void mark_fringe_data (void);
 #endif /* HAVE_WINDOW_SYSTEM */
 
-static struct Lisp_String *allocate_string P_ ((void));
-static void compact_small_strings P_ ((void));
-static void free_large_strings P_ ((void));
-static void sweep_strings P_ ((void));
+static struct Lisp_String *allocate_string (void);
+static void compact_small_strings (void);
+static void free_large_strings (void);
+static void sweep_strings (void);
 
 extern int message_enable_multibyte;
 
@@ -369,9 +365,9 @@ enum mem_type
   MEM_TYPE_VECTORLIKE
 };
 
-static POINTER_TYPE *lisp_align_malloc P_ ((size_t, enum mem_type));
-static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type));
-void refill_memory_reserve ();
+static POINTER_TYPE *lisp_align_malloc (size_t, enum mem_type);
+static POINTER_TYPE *lisp_malloc (size_t, enum mem_type);
+void refill_memory_reserve (void);
 
 
 #if GC_MARK_STACK || defined GC_MALLOC_CHECK
@@ -452,31 +448,31 @@ static void *min_heap_address, *max_heap_address;
 static struct mem_node mem_z;
 #define MEM_NIL &mem_z
 
-static POINTER_TYPE *lisp_malloc P_ ((size_t, enum mem_type));
-static struct Lisp_Vector *allocate_vectorlike P_ ((EMACS_INT));
-static void lisp_free P_ ((POINTER_TYPE *));
-static void mark_stack P_ ((void));
-static int live_vector_p P_ ((struct mem_node *, void *));
-static int live_buffer_p P_ ((struct mem_node *, void *));
-static int live_string_p P_ ((struct mem_node *, void *));
-static int live_cons_p P_ ((struct mem_node *, void *));
-static int live_symbol_p P_ ((struct mem_node *, void *));
-static int live_float_p P_ ((struct mem_node *, void *));
-static int live_misc_p P_ ((struct mem_node *, void *));
-static void mark_maybe_object P_ ((Lisp_Object));
-static void mark_memory P_ ((void *, void *, int));
-static void mem_init P_ ((void));
-static struct mem_node *mem_insert P_ ((void *, void *, enum mem_type));
-static void mem_insert_fixup P_ ((struct mem_node *));
-static void mem_rotate_left P_ ((struct mem_node *));
-static void mem_rotate_right P_ ((struct mem_node *));
-static void mem_delete P_ ((struct mem_node *));
-static void mem_delete_fixup P_ ((struct mem_node *));
-static INLINE struct mem_node *mem_find P_ ((void *));
+static POINTER_TYPE *lisp_malloc (size_t, enum mem_type);
+static struct Lisp_Vector *allocate_vectorlike (EMACS_INT);
+static void lisp_free (POINTER_TYPE *);
+static void mark_stack (void);
+static int live_vector_p (struct mem_node *, void *);
+static int live_buffer_p (struct mem_node *, void *);
+static int live_string_p (struct mem_node *, void *);
+static int live_cons_p (struct mem_node *, void *);
+static int live_symbol_p (struct mem_node *, void *);
+static int live_float_p (struct mem_node *, void *);
+static int live_misc_p (struct mem_node *, void *);
+static void mark_maybe_object (Lisp_Object);
+static void mark_memory (void *, void *, int);
+static void mem_init (void);
+static struct mem_node *mem_insert (void *, void *, enum mem_type);
+static void mem_insert_fixup (struct mem_node *);
+static void mem_rotate_left (struct mem_node *);
+static void mem_rotate_right (struct mem_node *);
+static void mem_delete (struct mem_node *);
+static void mem_delete_fixup (struct mem_node *);
+static INLINE struct mem_node *mem_find (void *);
 
 
 #if GC_MARK_STACK == GC_MARK_STACK_CHECK_GCPROS
-static void check_gcpros P_ ((void));
+static void check_gcpros (void);
 #endif
 
 #endif /* GC_MARK_STACK || GC_MALLOC_CHECK */
@@ -495,7 +491,7 @@ static Lisp_Object *staticvec[NSTATICS] = {&Vpurify_flag};
 
 static int staticidx = 0;
 
-static POINTER_TYPE *pure_alloc P_ ((size_t, int));
+static POINTER_TYPE *pure_alloc (size_t, int);
 
 
 /* Value is SZ rounded up to the next multiple of ALIGNMENT.
@@ -514,8 +510,7 @@ static POINTER_TYPE *pure_alloc P_ ((size_t, int));
 /* Function malloc calls this if it finds we are near exhausting storage.  */
 
 void
-malloc_warning (str)
-     char *str;
+malloc_warning (const char *str)
 {
   pending_malloc_warning = str;
 }
@@ -524,7 +519,7 @@ malloc_warning (str)
 /* Display an already-pending malloc warning.  */
 
 void
-display_malloc_warning ()
+display_malloc_warning (void)
 {
   call3 (intern ("display-warning"),
         intern ("alloc"),
@@ -543,7 +538,7 @@ display_malloc_warning ()
 /* Called if we can't allocate relocatable space for a buffer.  */
 
 void
-buffer_memory_full ()
+buffer_memory_full (void)
 {
   /* If buffers use the relocating allocator, no need to free
      spare_memory, because we may have plenty of malloc space left
@@ -637,10 +632,12 @@ overrun_check_malloc (size)
   val = (unsigned char *) malloc (size + overhead);
   if (val && check_depth == 1)
     {
-      bcopy (xmalloc_overrun_check_header, val, XMALLOC_OVERRUN_CHECK_SIZE - 4);
+      memcpy (val, xmalloc_overrun_check_header,
+             XMALLOC_OVERRUN_CHECK_SIZE - 4);
       val += XMALLOC_OVERRUN_CHECK_SIZE;
       XMALLOC_PUT_SIZE(val, size);
-      bcopy (xmalloc_overrun_check_trailer, val + size, XMALLOC_OVERRUN_CHECK_SIZE);
+      memcpy (val + size, xmalloc_overrun_check_trailer,
+             XMALLOC_OVERRUN_CHECK_SIZE);
     }
   --check_depth;
   return (POINTER_TYPE *)val;
@@ -660,28 +657,29 @@ overrun_check_realloc (block, size)
 
   if (val
       && check_depth == 1
-      && bcmp (xmalloc_overrun_check_header,
-              val - XMALLOC_OVERRUN_CHECK_SIZE,
-              XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0)
+      && memcmp (xmalloc_overrun_check_header,
+                val - XMALLOC_OVERRUN_CHECK_SIZE,
+                XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0)
     {
       size_t osize = XMALLOC_GET_SIZE (val);
-      if (bcmp (xmalloc_overrun_check_trailer,
-               val + osize,
-               XMALLOC_OVERRUN_CHECK_SIZE))
+      if (memcmp (xmalloc_overrun_check_trailer, val + osize,
+                 XMALLOC_OVERRUN_CHECK_SIZE))
        abort ();
-      bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE);
+      memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE);
       val -= XMALLOC_OVERRUN_CHECK_SIZE;
-      bzero (val, XMALLOC_OVERRUN_CHECK_SIZE);
+      memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE);
     }
 
   val = (unsigned char *) realloc ((POINTER_TYPE *)val, size + overhead);
 
   if (val && check_depth == 1)
     {
-      bcopy (xmalloc_overrun_check_header, val, XMALLOC_OVERRUN_CHECK_SIZE - 4);
+      memcpy (val, xmalloc_overrun_check_header,
+             XMALLOC_OVERRUN_CHECK_SIZE - 4);
       val += XMALLOC_OVERRUN_CHECK_SIZE;
       XMALLOC_PUT_SIZE(val, size);
-      bcopy (xmalloc_overrun_check_trailer, val + size, XMALLOC_OVERRUN_CHECK_SIZE);
+      memcpy (val + size, xmalloc_overrun_check_trailer,
+             XMALLOC_OVERRUN_CHECK_SIZE);
     }
   --check_depth;
   return (POINTER_TYPE *)val;
@@ -698,22 +696,21 @@ overrun_check_free (block)
   ++check_depth;
   if (val
       && check_depth == 1
-      && bcmp (xmalloc_overrun_check_header,
-              val - XMALLOC_OVERRUN_CHECK_SIZE,
-              XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0)
+      && memcmp (xmalloc_overrun_check_header,
+                val - XMALLOC_OVERRUN_CHECK_SIZE,
+                XMALLOC_OVERRUN_CHECK_SIZE - 4) == 0)
     {
       size_t osize = XMALLOC_GET_SIZE (val);
-      if (bcmp (xmalloc_overrun_check_trailer,
-               val + osize,
-               XMALLOC_OVERRUN_CHECK_SIZE))
+      if (memcmp (xmalloc_overrun_check_trailer, val + osize,
+                 XMALLOC_OVERRUN_CHECK_SIZE))
        abort ();
 #ifdef XMALLOC_CLEAR_FREE_MEMORY
       val -= XMALLOC_OVERRUN_CHECK_SIZE;
       memset (val, 0xff, osize + XMALLOC_OVERRUN_CHECK_SIZE*2);
 #else
-      bzero (val + osize, XMALLOC_OVERRUN_CHECK_SIZE);
+      memset (val + osize, 0, XMALLOC_OVERRUN_CHECK_SIZE);
       val -= XMALLOC_OVERRUN_CHECK_SIZE;
-      bzero (val, XMALLOC_OVERRUN_CHECK_SIZE);
+      memset (val, 0, XMALLOC_OVERRUN_CHECK_SIZE);
 #endif
     }
 
@@ -742,8 +739,7 @@ overrun_check_free (block)
 /* Like malloc but check for no memory and block interrupt input..  */
 
 POINTER_TYPE *
-xmalloc (size)
-     size_t size;
+xmalloc (size_t size)
 {
   register POINTER_TYPE *val;
 
@@ -760,9 +756,7 @@ xmalloc (size)
 /* Like realloc but check for no memory and block interrupt input..  */
 
 POINTER_TYPE *
-xrealloc (block, size)
-     POINTER_TYPE *block;
-     size_t size;
+xrealloc (POINTER_TYPE *block, size_t size)
 {
   register POINTER_TYPE *val;
 
@@ -783,8 +777,7 @@ xrealloc (block, size)
 /* Like free but block interrupt input.  */
 
 void
-xfree (block)
-     POINTER_TYPE *block;
+xfree (POINTER_TYPE *block)
 {
   if (!block)
     return;
@@ -800,12 +793,11 @@ xfree (block)
 /* Like strdup, but uses xmalloc.  */
 
 char *
-xstrdup (s)
-     const char *s;
+xstrdup (const char *s)
 {
   size_t len = strlen (s) + 1;
   char *p = (char *) xmalloc (len);
-  bcopy (s, p, len);
+  memcpy (p, s, len);
   return p;
 }
 
@@ -813,8 +805,7 @@ xstrdup (s)
 /* Unwind for SAFE_ALLOCA */
 
 Lisp_Object
-safe_alloca_unwind (arg)
-     Lisp_Object arg;
+safe_alloca_unwind (Lisp_Object arg)
 {
   register struct Lisp_Save_Value *p = XSAVE_VALUE (arg);
 
@@ -835,9 +826,7 @@ static void *lisp_malloc_loser;
 #endif
 
 static POINTER_TYPE *
-lisp_malloc (nbytes, type)
-     size_t nbytes;
-     enum mem_type type;
+lisp_malloc (size_t nbytes, enum mem_type type)
 {
   register void *val;
 
@@ -881,8 +870,7 @@ lisp_malloc (nbytes, type)
    call to lisp_malloc.  */
 
 static void
-lisp_free (block)
-     POINTER_TYPE *block;
+lisp_free (POINTER_TYPE *block)
 {
   MALLOC_BLOCK_INPUT;
   free (block);
@@ -981,9 +969,7 @@ static struct ablock *free_ablock;
    Alignment is on a multiple of BLOCK_ALIGN and `nbytes' has to be
    smaller or equal to BLOCK_BYTES.  */
 static POINTER_TYPE *
-lisp_align_malloc (nbytes, type)
-     size_t nbytes;
-     enum mem_type type;
+lisp_align_malloc (size_t nbytes, enum mem_type type)
 {
   void *base, *val;
   struct ablocks *abase;
@@ -1090,8 +1076,7 @@ lisp_align_malloc (nbytes, type)
 }
 
 static void
-lisp_align_free (block)
-     POINTER_TYPE *block;
+lisp_align_free (POINTER_TYPE *block)
 {
   struct ablock *ablock = block;
   struct ablocks *abase = ABLOCK_ABASE (ablock);
@@ -1136,7 +1121,7 @@ lisp_align_free (block)
    a call to lisp_malloc.  */
 
 struct buffer *
-allocate_buffer ()
+allocate_buffer (void)
 {
   struct buffer *b
     = (struct buffer *) lisp_malloc (sizeof (struct buffer),
@@ -1164,21 +1149,19 @@ allocate_buffer ()
    there's no need to block input around malloc.  */
 
 #ifndef DOUG_LEA_MALLOC
-extern void * (*__malloc_hook) P_ ((size_t, const void *));
-extern void * (*__realloc_hook) P_ ((void *, size_t, const void *));
-extern void (*__free_hook) P_ ((void *, const void *));
+extern void * (*__malloc_hook) (size_t, const void *);
+extern void * (*__realloc_hook) (void *, size_t, const void *);
+extern void (*__free_hook) (void *, const void *);
 /* Else declared in malloc.h, perhaps with an extra arg.  */
 #endif /* DOUG_LEA_MALLOC */
-static void * (*old_malloc_hook) P_ ((size_t, const void *));
-static void * (*old_realloc_hook) P_ ((void *,  size_t, const void*));
-static void (*old_free_hook) P_ ((void*, const void*));
+static void * (*old_malloc_hook) (size_t, const void *);
+static void * (*old_realloc_hook) (void *,  size_t, const void*);
+static void (*old_free_hook) (void*, const void*);
 
 /* This function is used as the hook for free to call.  */
 
 static void
-emacs_blocked_free (ptr, ptr2)
-     void *ptr;
-     const void *ptr2;
+emacs_blocked_free (void *ptr, const void *ptr2)
 {
   BLOCK_INPUT_ALLOC;
 
@@ -1226,9 +1209,7 @@ emacs_blocked_free (ptr, ptr2)
 /* This function is the malloc hook that Emacs uses.  */
 
 static void *
-emacs_blocked_malloc (size, ptr)
-     size_t size;
-     const void *ptr;
+emacs_blocked_malloc (size_t size, const void *ptr)
 {
   void *value;
 
@@ -1275,10 +1256,7 @@ emacs_blocked_malloc (size, ptr)
 /* This function is the realloc hook that Emacs uses.  */
 
 static void *
-emacs_blocked_realloc (ptr, size, ptr2)
-     void *ptr;
-     size_t size;
-     const void *ptr2;
+emacs_blocked_realloc (void *ptr, size_t size, const void *ptr2)
 {
   void *value;
 
@@ -1352,7 +1330,7 @@ reset_malloc_hooks ()
 /* Called from main to set up malloc to use our hooks.  */
 
 void
-uninterrupt_malloc ()
+uninterrupt_malloc (void)
 {
 #ifdef HAVE_GTK_AND_PTHREAD
 #ifdef DOUG_LEA_MALLOC
@@ -1434,7 +1412,7 @@ static int n_interval_blocks;
 /* Initialize interval allocation.  */
 
 static void
-init_intervals ()
+init_intervals (void)
 {
   interval_block = NULL;
   interval_block_index = INTERVAL_BLOCK_SIZE;
@@ -1446,7 +1424,7 @@ init_intervals ()
 /* Return a new interval.  */
 
 INTERVAL
-make_interval ()
+make_interval (void)
 {
   INTERVAL val;
 
@@ -1489,9 +1467,7 @@ make_interval ()
 /* Mark Lisp objects in interval I. */
 
 static void
-mark_interval (i, dummy)
-     register INTERVAL i;
-     Lisp_Object dummy;
+mark_interval (register INTERVAL i, Lisp_Object dummy)
 {
   eassert (!i->gcmarkbit);             /* Intervals are never shared.  */
   i->gcmarkbit = 1;
@@ -1503,8 +1479,7 @@ mark_interval (i, dummy)
    use the macro MARK_INTERVAL_TREE instead.  */
 
 static void
-mark_interval_tree (tree)
-     register INTERVAL tree;
+mark_interval_tree (register INTERVAL tree)
 {
   /* No need to test if this tree has been marked already; this
      function is always called through the MARK_INTERVAL_TREE macro,
@@ -1751,7 +1726,7 @@ static char string_overrun_cookie[GC_STRING_OVERRUN_COOKIE_SIZE] =
 /* Initialize string allocation.  Called from init_alloc_once.  */
 
 static void
-init_strings ()
+init_strings (void)
 {
   total_strings = total_free_strings = total_string_size = 0;
   oldest_sblock = current_sblock = large_sblocks = NULL;
@@ -1767,8 +1742,8 @@ init_strings ()
 
 static int check_string_bytes_count;
 
-static void check_string_bytes P_ ((int));
-static void check_sblock P_ ((struct sblock *));
+static void check_string_bytes (int);
+static void check_sblock (struct sblock *);
 
 #define CHECK_STRING_BYTES(S)  STRING_BYTES (S)
 
@@ -1873,7 +1848,7 @@ check_string_free_list ()
 /* Return a new Lisp_String.  */
 
 static struct Lisp_String *
-allocate_string ()
+allocate_string (void)
 {
   struct Lisp_String *s;
 
@@ -1889,7 +1864,7 @@ allocate_string ()
       int i;
 
       b = (struct string_block *) lisp_malloc (sizeof *b, MEM_TYPE_STRING);
-      bzero (b, sizeof *b);
+      memset (b, 0, sizeof *b);
       b->next = string_blocks;
       string_blocks = b;
       ++n_string_blocks;
@@ -1913,7 +1888,7 @@ allocate_string ()
   MALLOC_UNBLOCK_INPUT;
 
   /* Probably not strictly necessary, but play it safe.  */
-  bzero (s, sizeof *s);
+  memset (s, 0, sizeof *s);
 
   --total_free_strings;
   ++total_strings;
@@ -1944,9 +1919,7 @@ allocate_string ()
    S->data if it was initially non-null.  */
 
 void
-allocate_string_data (s, nchars, nbytes)
-     struct Lisp_String *s;
-     int nchars, nbytes;
+allocate_string_data (struct Lisp_String *s, int nchars, int nbytes)
 {
   struct sdata *data, *old_data;
   struct sblock *b;
@@ -2023,8 +1996,7 @@ allocate_string_data (s, nchars, nbytes)
   s->size_byte = nbytes;
   s->data[nbytes] = '\0';
 #ifdef GC_CHECK_STRING_OVERRUN
-  bcopy (string_overrun_cookie, (char *) data + needed,
-        GC_STRING_OVERRUN_COOKIE_SIZE);
+  memcpy (data + needed, string_overrun_cookie, GC_STRING_OVERRUN_COOKIE_SIZE);
 #endif
 
   /* If S had already data assigned, mark that as free by setting its
@@ -2043,7 +2015,7 @@ allocate_string_data (s, nchars, nbytes)
 /* Sweep and compact strings.  */
 
 static void
-sweep_strings ()
+sweep_strings (void)
 {
   struct string_block *b, *next;
   struct string_block *live_blocks = NULL;
@@ -2143,7 +2115,7 @@ sweep_strings ()
 /* Free dead large strings.  */
 
 static void
-free_large_strings ()
+free_large_strings (void)
 {
   struct sblock *b, *next;
   struct sblock *live_blocks = NULL;
@@ -2169,7 +2141,7 @@ free_large_strings ()
    data of live strings after compaction.  */
 
 static void
-compact_small_strings ()
+compact_small_strings (void)
 {
   struct sblock *b, *tb, *next;
   struct sdata *from, *to, *end, *tb_end;
@@ -2215,9 +2187,9 @@ compact_small_strings ()
          from_end = (struct sdata *) ((char *) from + nbytes + GC_STRING_EXTRA);
 
 #ifdef GC_CHECK_STRING_OVERRUN
-         if (bcmp (string_overrun_cookie,
-                   ((char *) from_end) - GC_STRING_OVERRUN_COOKIE_SIZE,
-                   GC_STRING_OVERRUN_COOKIE_SIZE))
+         if (memcmp (string_overrun_cookie,
+                     (char *) from_end - GC_STRING_OVERRUN_COOKIE_SIZE,
+                     GC_STRING_OVERRUN_COOKIE_SIZE))
            abort ();
 #endif
 
@@ -2239,7 +2211,7 @@ compact_small_strings ()
              if (from != to)
                {
                  xassert (tb != b || to <= from);
-                 safe_bcopy ((char *) from, (char *) to, nbytes + GC_STRING_EXTRA);
+                 memmove (to, from, nbytes + GC_STRING_EXTRA);
                  to->string->data = SDATA_DATA (to);
                }
 
@@ -2267,8 +2239,7 @@ DEFUN ("make-string", Fmake_string, Smake_string, 2, 2, 0,
        doc: /* Return a newly created string of length LENGTH, with INIT in each element.
 LENGTH must be an integer.
 INIT must be an integer that represents a character.  */)
-     (length, init)
-     Lisp_Object length, init;
+  (Lisp_Object length, Lisp_Object init)
 {
   register Lisp_Object val;
   register unsigned char *p, *end;
@@ -2298,7 +2269,7 @@ INIT must be an integer that represents a character.  */)
       end = p + nbytes;
       while (p != end)
        {
-         bcopy (str, p, len);
+         memcpy (p, str, len);
          p += len;
        }
     }
@@ -2311,8 +2282,7 @@ INIT must be an integer that represents a character.  */)
 DEFUN ("make-bool-vector", Fmake_bool_vector, Smake_bool_vector, 2, 2, 0,
        doc: /* Return a new bool-vector of length LENGTH, using INIT for each element.
 LENGTH must be a number.  INIT matters only in whether it is t or nil.  */)
-     (length, init)
-     Lisp_Object length, init;
+  (Lisp_Object length, Lisp_Object init)
 {
   register Lisp_Object val;
   struct Lisp_Bool_Vector *p;
@@ -2357,9 +2327,7 @@ LENGTH must be a number.  INIT matters only in whether it is t or nil.  */)
    multibyte, depending on the contents.  */
 
 Lisp_Object
-make_string (contents, nbytes)
-     const char *contents;
-     int nbytes;
+make_string (const char *contents, int nbytes)
 {
   register Lisp_Object val;
   int nchars, multibyte_nbytes;
@@ -2378,13 +2346,11 @@ make_string (contents, nbytes)
 /* Make an unibyte string from LENGTH bytes at CONTENTS.  */
 
 Lisp_Object
-make_unibyte_string (contents, length)
-     const char *contents;
-     int length;
+make_unibyte_string (const char *contents, int length)
 {
   register Lisp_Object val;
   val = make_uninit_string (length);
-  bcopy (contents, SDATA (val), length);
+  memcpy (SDATA (val), contents, length);
   STRING_SET_UNIBYTE (val);
   return val;
 }
@@ -2394,13 +2360,11 @@ make_unibyte_string (contents, length)
    bytes at CONTENTS.  */
 
 Lisp_Object
-make_multibyte_string (contents, nchars, nbytes)
-     const char *contents;
-     int nchars, nbytes;
+make_multibyte_string (const char *contents, int nchars, int nbytes)
 {
   register Lisp_Object val;
   val = make_uninit_multibyte_string (nchars, nbytes);
-  bcopy (contents, SDATA (val), nbytes);
+  memcpy (SDATA (val), contents, nbytes);
   return val;
 }
 
@@ -2409,13 +2373,11 @@ make_multibyte_string (contents, nchars, nbytes)
    CONTENTS.  It is a multibyte string if NBYTES != NCHARS.  */
 
 Lisp_Object
-make_string_from_bytes (contents, nchars, nbytes)
-     const char *contents;
-     int nchars, nbytes;
+make_string_from_bytes (const char *contents, int nchars, int nbytes)
 {
   register Lisp_Object val;
   val = make_uninit_multibyte_string (nchars, nbytes);
-  bcopy (contents, SDATA (val), nbytes);
+  memcpy (SDATA (val), contents, nbytes);
   if (SBYTES (val) == SCHARS (val))
     STRING_SET_UNIBYTE (val);
   return val;
@@ -2428,10 +2390,7 @@ make_string_from_bytes (contents, nchars, nbytes)
    characters by itself.  */
 
 Lisp_Object
-make_specified_string (contents, nchars, nbytes, multibyte)
-     const char *contents;
-     int nchars, nbytes;
-     int multibyte;
+make_specified_string (const char *contents, int nchars, int nbytes, int multibyte)
 {
   register Lisp_Object val;
 
@@ -2443,7 +2402,7 @@ make_specified_string (contents, nchars, nbytes, multibyte)
        nchars = nbytes;
     }
   val = make_uninit_multibyte_string (nchars, nbytes);
-  bcopy (contents, SDATA (val), nbytes);
+  memcpy (SDATA (val), contents, nbytes);
   if (!multibyte)
     STRING_SET_UNIBYTE (val);
   return val;
@@ -2454,8 +2413,7 @@ make_specified_string (contents, nchars, nbytes, multibyte)
    data warrants.  */
 
 Lisp_Object
-build_string (str)
-     const char *str;
+build_string (const char *str)
 {
   return make_string (str, strlen (str));
 }
@@ -2465,8 +2423,7 @@ build_string (str)
    occupying LENGTH bytes.  */
 
 Lisp_Object
-make_uninit_string (length)
-     int length;
+make_uninit_string (int length)
 {
   Lisp_Object val;
 
@@ -2482,8 +2439,7 @@ make_uninit_string (length)
    which occupy NBYTES bytes.  */
 
 Lisp_Object
-make_uninit_multibyte_string (nchars, nbytes)
-     int nchars, nbytes;
+make_uninit_multibyte_string (int nchars, int nbytes)
 {
   Lisp_Object string;
   struct Lisp_String *s;
@@ -2573,7 +2529,7 @@ struct Lisp_Float *float_free_list;
 /* Initialize float allocation.  */
 
 static void
-init_float ()
+init_float (void)
 {
   float_block = NULL;
   float_block_index = FLOAT_BLOCK_SIZE; /* Force alloc of new float_block.   */
@@ -2585,8 +2541,7 @@ init_float ()
 /* Explicitly free a float cell by putting it on the free-list.  */
 
 static void
-free_float (ptr)
-     struct Lisp_Float *ptr;
+free_float (struct Lisp_Float *ptr)
 {
   ptr->u.chain = float_free_list;
   float_free_list = ptr;
@@ -2596,8 +2551,7 @@ free_float (ptr)
 /* Return a new float object with value FLOAT_VALUE.  */
 
 Lisp_Object
-make_float (float_value)
-     double float_value;
+make_float (double float_value)
 {
   register Lisp_Object val;
 
@@ -2621,7 +2575,7 @@ make_float (float_value)
          new = (struct float_block *) lisp_align_malloc (sizeof *new,
                                                          MEM_TYPE_FLOAT);
          new->next = float_block;
-         bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits);
+         memset (new->gcmarkbits, 0, sizeof new->gcmarkbits);
          float_block = new;
          float_block_index = 0;
          n_float_blocks++;
@@ -2697,7 +2651,7 @@ static int n_cons_blocks;
 /* Initialize cons allocation.  */
 
 static void
-init_cons ()
+init_cons (void)
 {
   cons_block = NULL;
   cons_block_index = CONS_BLOCK_SIZE; /* Force alloc of new cons_block.  */
@@ -2709,8 +2663,7 @@ init_cons ()
 /* Explicitly free a cons cell by putting it on the free-list.  */
 
 void
-free_cons (ptr)
-     struct Lisp_Cons *ptr;
+free_cons (struct Lisp_Cons *ptr)
 {
   ptr->u.chain = cons_free_list;
 #if GC_MARK_STACK
@@ -2721,8 +2674,7 @@ free_cons (ptr)
 
 DEFUN ("cons", Fcons, Scons, 2, 2, 0,
        doc: /* Create a new cons, give it CAR and CDR as components, and return it.  */)
-     (car, cdr)
-     Lisp_Object car, cdr;
+  (Lisp_Object car, Lisp_Object cdr)
 {
   register Lisp_Object val;
 
@@ -2744,7 +2696,7 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
          register struct cons_block *new;
          new = (struct cons_block *) lisp_align_malloc (sizeof *new,
                                                         MEM_TYPE_CONS);
-         bzero ((char *) new->gcmarkbits, sizeof new->gcmarkbits);
+         memset (new->gcmarkbits, 0, sizeof new->gcmarkbits);
          new->next = cons_block;
          cons_block = new;
          cons_block_index = 0;
@@ -2766,7 +2718,7 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
 
 /* Get an error now if there's any junk in the cons free list.  */
 void
-check_cons_list ()
+check_cons_list (void)
 {
 #ifdef GC_CHECK_CONS_LIST
   struct Lisp_Cons *tail = cons_free_list;
@@ -2779,39 +2731,34 @@ check_cons_list ()
 /* Make a list of 1, 2, 3, 4 or 5 specified objects.  */
 
 Lisp_Object
-list1 (arg1)
-     Lisp_Object arg1;
+list1 (Lisp_Object arg1)
 {
   return Fcons (arg1, Qnil);
 }
 
 Lisp_Object
-list2 (arg1, arg2)
-     Lisp_Object arg1, arg2;
+list2 (Lisp_Object arg1, Lisp_Object arg2)
 {
   return Fcons (arg1, Fcons (arg2, Qnil));
 }
 
 
 Lisp_Object
-list3 (arg1, arg2, arg3)
-     Lisp_Object arg1, arg2, arg3;
+list3 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
 {
   return Fcons (arg1, Fcons (arg2, Fcons (arg3, Qnil)));
 }
 
 
 Lisp_Object
-list4 (arg1, arg2, arg3, arg4)
-     Lisp_Object arg1, arg2, arg3, arg4;
+list4 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4)
 {
   return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4, Qnil))));
 }
 
 
 Lisp_Object
-list5 (arg1, arg2, arg3, arg4, arg5)
-     Lisp_Object arg1, arg2, arg3, arg4, arg5;
+list5 (Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3, Lisp_Object arg4, Lisp_Object arg5)
 {
   return Fcons (arg1, Fcons (arg2, Fcons (arg3, Fcons (arg4,
                                                       Fcons (arg5, Qnil)))));
@@ -2822,9 +2769,7 @@ DEFUN ("list", Flist, Slist, 0, MANY, 0,
        doc: /* Return a newly created list with specified arguments as elements.
 Any number of arguments, even zero arguments, are allowed.
 usage: (list &rest OBJECTS)  */)
-     (nargs, args)
-     int nargs;
-     register Lisp_Object *args;
+  (int nargs, register Lisp_Object *args)
 {
   register Lisp_Object val;
   val = Qnil;
@@ -2840,8 +2785,7 @@ usage: (list &rest OBJECTS)  */)
 
 DEFUN ("make-list", Fmake_list, Smake_list, 2, 2, 0,
        doc: /* Return a newly created list of length LENGTH, with each element being INIT.  */)
-     (length, init)
-     register Lisp_Object length, init;
+  (register Lisp_Object length, Lisp_Object init)
 {
   register Lisp_Object val;
   register int size;
@@ -2904,8 +2848,7 @@ static int n_vectors;
    with room for LEN Lisp_Objects.  */
 
 static struct Lisp_Vector *
-allocate_vectorlike (len)
-     EMACS_INT len;
+allocate_vectorlike (EMACS_INT len)
 {
   struct Lisp_Vector *p;
   size_t nbytes;
@@ -2946,8 +2889,7 @@ allocate_vectorlike (len)
 /* Allocate a vector with NSLOTS slots.  */
 
 struct Lisp_Vector *
-allocate_vector (nslots)
-     EMACS_INT nslots;
+allocate_vector (EMACS_INT nslots)
 {
   struct Lisp_Vector *v = allocate_vectorlike (nslots);
   v->size = nslots;
@@ -2958,9 +2900,7 @@ allocate_vector (nslots)
 /* Allocate other vector-like structures.  */
 
 struct Lisp_Vector *
-allocate_pseudovector (memlen, lisplen, tag)
-     int memlen, lisplen;
-     EMACS_INT tag;
+allocate_pseudovector (int memlen, int lisplen, EMACS_INT tag)
 {
   struct Lisp_Vector *v = allocate_vectorlike (memlen);
   EMACS_INT i;
@@ -2982,38 +2922,38 @@ allocate_hash_table (void)
 
 
 struct window *
-allocate_window ()
+allocate_window (void)
 {
   return ALLOCATE_PSEUDOVECTOR(struct window, current_matrix, PVEC_WINDOW);
 }
 
 
 struct terminal *
-allocate_terminal ()
+allocate_terminal (void)
 {
   struct terminal *t = ALLOCATE_PSEUDOVECTOR (struct terminal,
                                              next_terminal, PVEC_TERMINAL);
   /* Zero out the non-GC'd fields.  FIXME: This should be made unnecessary.  */
-  bzero (&(t->next_terminal),
-        ((char*)(t+1)) - ((char*)&(t->next_terminal)));
+  memset (&t->next_terminal, 0,
+         (char*) (t + 1) - (char*) &t->next_terminal);
 
   return t;
 }
 
 struct frame *
-allocate_frame ()
+allocate_frame (void)
 {
   struct frame *f = ALLOCATE_PSEUDOVECTOR (struct frame,
                                           face_cache, PVEC_FRAME);
   /* Zero out the non-GC'd fields.  FIXME: This should be made unnecessary.  */
-  bzero (&(f->face_cache),
-        ((char*)(f+1)) - ((char*)&(f->face_cache)));
+  memset (&f->face_cache, 0,
+         (char *) (f + 1) - (char *) &f->face_cache);
   return f;
 }
 
 
 struct Lisp_Process *
-allocate_process ()
+allocate_process (void)
 {
   return ALLOCATE_PSEUDOVECTOR (struct Lisp_Process, pid, PVEC_PROCESS);
 }
@@ -3022,8 +2962,7 @@ allocate_process ()
 DEFUN ("make-vector", Fmake_vector, Smake_vector, 2, 2, 0,
        doc: /* Return a newly created vector of length LENGTH, with each element being INIT.
 See also the function `vector'.  */)
-     (length, init)
-     register Lisp_Object length, init;
+  (register Lisp_Object length, Lisp_Object init)
 {
   Lisp_Object vector;
   register EMACS_INT sizei;
@@ -3079,9 +3018,7 @@ DEFUN ("vector", Fvector, Svector, 0, MANY, 0,
        doc: /* Return a newly created vector with specified arguments as elements.
 Any number of arguments, even zero arguments, are allowed.
 usage: (vector &rest OBJECTS)  */)
-     (nargs, args)
-     register int nargs;
-     Lisp_Object *args;
+  (register int nargs, Lisp_Object *args)
 {
   register Lisp_Object len, val;
   register int index;
@@ -3126,9 +3063,7 @@ stack size, (optional) doc string, and (optional) interactive spec.
 The first four arguments are required; at most six have any
 significance.
 usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INTERACTIVE-SPEC &rest ELEMENTS)  */)
-     (nargs, args)
-     register int nargs;
-     Lisp_Object *args;
+  (register int nargs, Lisp_Object *args)
 {
   register Lisp_Object len, val;
   register int index;
@@ -3144,7 +3079,7 @@ usage: (make-byte-code ARGLIST BYTE-CODE CONSTANTS DEPTH &optional DOCSTRING INT
   else
     val = Fmake_vector (len, Qnil);
 
-  if (STRINGP (args[1]) && STRING_MULTIBYTE (args[1]))
+  if (nargs > 1 && STRINGP (args[1]) && STRING_MULTIBYTE (args[1]))
     /* BYTECODE-STRING must have been produced by Emacs 20.2 or the
        earlier because they produced a raw 8-bit string for byte-code
        and now such a byte-code string is loaded as multibyte while
@@ -3202,7 +3137,7 @@ static int n_symbol_blocks;
 /* Initialize symbol allocation.  */
 
 static void
-init_symbol ()
+init_symbol (void)
 {
   symbol_block = NULL;
   symbol_block_index = SYMBOL_BLOCK_SIZE;
@@ -3214,8 +3149,7 @@ init_symbol ()
 DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0,
        doc: /* Return a newly allocated uninterned symbol whose name is NAME.
 Its value and function definition are void, and its property list is nil.  */)
-     (name)
-     Lisp_Object name;
+  (Lisp_Object name)
 {
   register Lisp_Object val;
   register struct Lisp_Symbol *p;
@@ -3294,7 +3228,7 @@ static union Lisp_Misc *marker_free_list;
 static int n_marker_blocks;
 
 static void
-init_marker ()
+init_marker (void)
 {
   marker_block = NULL;
   marker_block_index = MARKER_BLOCK_SIZE;
@@ -3305,7 +3239,7 @@ init_marker ()
 /* Return a newly allocated Lisp_Misc object, with no substructure.  */
 
 Lisp_Object
-allocate_misc ()
+allocate_misc (void)
 {
   Lisp_Object val;
 
@@ -3347,8 +3281,7 @@ allocate_misc ()
 /* Free a Lisp_Misc object */
 
 void
-free_misc (misc)
-     Lisp_Object misc;
+free_misc (Lisp_Object misc)
 {
   XMISCTYPE (misc) = Lisp_Misc_Free;
   XMISC (misc)->u_free.chain = marker_free_list;
@@ -3362,9 +3295,7 @@ free_misc (misc)
    The unwind function can get the C values back using XSAVE_VALUE.  */
 
 Lisp_Object
-make_save_value (pointer, integer)
-     void *pointer;
-     int integer;
+make_save_value (void *pointer, int integer)
 {
   register Lisp_Object val;
   register struct Lisp_Save_Value *p;
@@ -3380,7 +3311,7 @@ make_save_value (pointer, integer)
 
 DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
        doc: /* Return a newly allocated marker which does not point at any place.  */)
-     ()
+  (void)
 {
   register Lisp_Object val;
   register struct Lisp_Marker *p;
@@ -3399,8 +3330,7 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
 /* Put MARKER back on the free list after using it temporarily.  */
 
 void
-free_marker (marker)
-     Lisp_Object marker;
+free_marker (Lisp_Object marker)
 {
   unchain_marker (XMARKER (marker));
   free_misc (marker);
@@ -3414,9 +3344,7 @@ free_marker (marker)
    Any number of arguments, even zero arguments, are allowed.  */
 
 Lisp_Object
-make_event_array (nargs, args)
-     register int nargs;
-     Lisp_Object *args;
+make_event_array (register int nargs, Lisp_Object *args)
 {
   int i;
 
@@ -3456,7 +3384,7 @@ make_event_array (nargs, args)
 /* Called if malloc returns zero.  */
 
 void
-memory_full ()
+memory_full (void)
 {
   int i;
 
@@ -3496,7 +3424,7 @@ memory_full ()
    and also directly from this file, in case we're not using ralloc.c.  */
 
 void
-refill_memory_reserve ()
+refill_memory_reserve (void)
 {
 #ifndef SYSTEM_MALLOC
   if (spare_memory[0] == 0)
@@ -3544,7 +3472,7 @@ refill_memory_reserve ()
 /* Initialize this part of alloc.c.  */
 
 static void
-mem_init ()
+mem_init (void)
 {
   mem_z.left = mem_z.right = MEM_NIL;
   mem_z.parent = NULL;
@@ -3558,8 +3486,7 @@ mem_init ()
    MEM_NIL if there is no node in the tree containing START.  */
 
 static INLINE struct mem_node *
-mem_find (start)
-     void *start;
+mem_find (void *start)
 {
   struct mem_node *p;
 
@@ -3582,9 +3509,7 @@ mem_find (start)
    pointer to the node that was inserted.  */
 
 static struct mem_node *
-mem_insert (start, end, type)
-     void *start, *end;
-     enum mem_type type;
+mem_insert (void *start, void *end, enum mem_type type)
 {
   struct mem_node *c, *parent, *x;
 
@@ -3656,8 +3581,7 @@ mem_insert (start, end, type)
    balance the tree, after node X has been inserted; X is always red.  */
 
 static void
-mem_insert_fixup (x)
-     struct mem_node *x;
+mem_insert_fixup (struct mem_node *x)
 {
   while (x != mem_root && x->parent->color == MEM_RED)
     {
@@ -3735,8 +3659,7 @@ mem_insert_fixup (x)
        b   c            a   b  */
 
 static void
-mem_rotate_left (x)
-     struct mem_node *x;
+mem_rotate_left (struct mem_node *x)
 {
   struct mem_node *y;
 
@@ -3775,8 +3698,7 @@ mem_rotate_left (x)
     a   b                  b   c  */
 
 static void
-mem_rotate_right (x)
-     struct mem_node *x;
+mem_rotate_right (struct mem_node *x)
 {
   struct mem_node *y = x->left;
 
@@ -3805,8 +3727,7 @@ mem_rotate_right (x)
 /* Delete node Z from the tree.  If Z is null or MEM_NIL, do nothing.  */
 
 static void
-mem_delete (z)
-     struct mem_node *z;
+mem_delete (struct mem_node *z)
 {
   struct mem_node *x, *y;
 
@@ -3860,8 +3781,7 @@ mem_delete (z)
    deletion.  */
 
 static void
-mem_delete_fixup (x)
-     struct mem_node *x;
+mem_delete_fixup (struct mem_node *x)
 {
   while (x != mem_root && x->color == MEM_BLACK)
     {
@@ -3942,9 +3862,7 @@ mem_delete_fixup (x)
    the heap.  M is a pointer to the mem_block for P.  */
 
 static INLINE int
-live_string_p (m, p)
-     struct mem_node *m;
-     void *p;
+live_string_p (struct mem_node *m, void *p)
 {
   if (m->type == MEM_TYPE_STRING)
     {
@@ -3967,9 +3885,7 @@ live_string_p (m, p)
    the heap.  M is a pointer to the mem_block for P.  */
 
 static INLINE int
-live_cons_p (m, p)
-     struct mem_node *m;
-     void *p;
+live_cons_p (struct mem_node *m, void *p)
 {
   if (m->type == MEM_TYPE_CONS)
     {
@@ -3995,9 +3911,7 @@ live_cons_p (m, p)
    the heap.  M is a pointer to the mem_block for P.  */
 
 static INLINE int
-live_symbol_p (m, p)
-     struct mem_node *m;
-     void *p;
+live_symbol_p (struct mem_node *m, void *p)
 {
   if (m->type == MEM_TYPE_SYMBOL)
     {
@@ -4023,9 +3937,7 @@ live_symbol_p (m, p)
    the heap.  M is a pointer to the mem_block for P.  */
 
 static INLINE int
-live_float_p (m, p)
-     struct mem_node *m;
-     void *p;
+live_float_p (struct mem_node *m, void *p)
 {
   if (m->type == MEM_TYPE_FLOAT)
     {
@@ -4049,9 +3961,7 @@ live_float_p (m, p)
    the heap.  M is a pointer to the mem_block for P.  */
 
 static INLINE int
-live_misc_p (m, p)
-     struct mem_node *m;
-     void *p;
+live_misc_p (struct mem_node *m, void *p)
 {
   if (m->type == MEM_TYPE_MISC)
     {
@@ -4077,9 +3987,7 @@ live_misc_p (m, p)
    M is a pointer to the mem_block for P.  */
 
 static INLINE int
-live_vector_p (m, p)
-     struct mem_node *m;
-     void *p;
+live_vector_p (struct mem_node *m, void *p)
 {
   return (p == m->start && m->type == MEM_TYPE_VECTORLIKE);
 }
@@ -4089,9 +3997,7 @@ live_vector_p (m, p)
    pointer to the mem_block for P.  */
 
 static INLINE int
-live_buffer_p (m, p)
-     struct mem_node *m;
-     void *p;
+live_buffer_p (struct mem_node *m, void *p)
 {
   /* P must point to the start of the block, and the buffer
      must not have been killed.  */
@@ -4134,7 +4040,7 @@ static double avg_live;
 
 DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "",
        doc: /* Show information about live and zombie objects.  */)
-     ()
+  (void)
 {
   Lisp_Object args[8], zombie_list = Qnil;
   int i;
@@ -4157,8 +4063,7 @@ DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "",
 /* Mark OBJ if we can prove it's a Lisp_Object.  */
 
 static INLINE void
-mark_maybe_object (obj)
-     Lisp_Object obj;
+mark_maybe_object (Lisp_Object obj)
 {
   void *po = (void *) XPNTR (obj);
   struct mem_node *m = mem_find (po);
@@ -4221,8 +4126,7 @@ mark_maybe_object (obj)
    marked.  */
 
 static INLINE void
-mark_maybe_pointer (p)
-     void *p;
+mark_maybe_pointer (void *p)
 {
   struct mem_node *m;
 
@@ -4302,9 +4206,7 @@ mark_maybe_pointer (p)
    or END+OFFSET..START. */
 
 static void
-mark_memory (start, end, offset)
-     void *start, *end;
-     int offset;
+mark_memory (void *start, void *end, int offset)
 {
   Lisp_Object *p;
   void **pp;
@@ -4520,7 +4422,7 @@ dump_zombies ()
    equally on the stack.  */
 
 static void
-mark_stack ()
+mark_stack (void)
 {
   int i;
   /* jmp_buf may not be aligned enough on darwin-ppc64 */
@@ -4595,8 +4497,7 @@ mark_stack ()
 
 /* Determine whether it is safe to access memory at address P.  */
 static int
-valid_pointer_p (p)
-     void *p;
+valid_pointer_p (void *p)
 {
 #ifdef WINDOWSNT
   return w32_valid_pointer_p (p, 16);
@@ -4627,8 +4528,7 @@ valid_pointer_p (p)
    so it should only be used in code for manual debugging.  */
 
 int
-valid_lisp_object_p (obj)
-     Lisp_Object obj;
+valid_lisp_object_p (Lisp_Object obj)
 {
   void *p;
 #if GC_MARK_STACK
@@ -4706,9 +4606,7 @@ valid_lisp_object_p (obj)
    allocated.  TYPE < 0 means it's not used for a Lisp object.  */
 
 static POINTER_TYPE *
-pure_alloc (size, type)
-     size_t size;
-     int type;
+pure_alloc (size_t size, int type)
 {
   POINTER_TYPE *result;
 #ifdef USE_LSB_TAG
@@ -4762,7 +4660,7 @@ pure_alloc (size, type)
 /* Print a warning if PURESIZE is too small.  */
 
 void
-check_pure_size ()
+check_pure_size (void)
 {
   if (pure_bytes_used_before_overflow)
     message ("emacs:0:Pure Lisp storage overflow (approx. %d bytes needed)",
@@ -4775,9 +4673,7 @@ check_pure_size ()
    address.  Return NULL if not found.  */
 
 static char *
-find_string_data_in_pure (data, nbytes)
-     const char *data;
-     int nbytes;
+find_string_data_in_pure (const char *data, int nbytes)
 {
   int i, skip, bm_skip[256], last_char_skip, infinity, start, start_max;
   const unsigned char *p;
@@ -4846,10 +4742,7 @@ find_string_data_in_pure (data, nbytes)
    string; then the string is not protected from gc.  */
 
 Lisp_Object
-make_pure_string (data, nchars, nbytes, multibyte)
-     const char *data;
-     int nchars, nbytes;
-     int multibyte;
+make_pure_string (const char *data, int nchars, int nbytes, int multibyte)
 {
   Lisp_Object string;
   struct Lisp_String *s;
@@ -4859,7 +4752,7 @@ make_pure_string (data, nchars, nbytes, multibyte)
   if (s->data == NULL)
     {
       s->data = (unsigned char *) pure_alloc (nbytes + 1, -1);
-      bcopy (data, s->data, nbytes);
+      memcpy (s->data, data, nbytes);
       s->data[nbytes] = '\0';
     }
   s->size = nchars;
@@ -4892,8 +4785,7 @@ make_pure_c_string (const char *data)
    of CAR as car and CDR as cdr.  */
 
 Lisp_Object
-pure_cons (car, cdr)
-     Lisp_Object car, cdr;
+pure_cons (Lisp_Object car, Lisp_Object cdr)
 {
   register Lisp_Object new;
   struct Lisp_Cons *p;
@@ -4909,8 +4801,7 @@ pure_cons (car, cdr)
 /* Value is a float object with value NUM allocated from pure space.  */
 
 static Lisp_Object
-make_pure_float (num)
-     double num;
+make_pure_float (double num)
 {
   register Lisp_Object new;
   struct Lisp_Float *p;
@@ -4926,8 +4817,7 @@ make_pure_float (num)
    pure space.  */
 
 Lisp_Object
-make_pure_vector (len)
-     EMACS_INT len;
+make_pure_vector (EMACS_INT len)
 {
   Lisp_Object new;
   struct Lisp_Vector *p;
@@ -4944,8 +4834,7 @@ DEFUN ("purecopy", Fpurecopy, Spurecopy, 1, 1, 0,
        doc: /* Make a copy of object OBJ in pure storage.
 Recursively copies contents of vectors and cons cells.
 Does not copy symbols.  Copies strings without text properties.  */)
-     (obj)
-     register Lisp_Object obj;
+  (register Lisp_Object obj)
 {
   if (NILP (Vpurify_flag))
     return obj;
@@ -5010,8 +4899,7 @@ Does not copy symbols.  Copies strings without text properties.  */)
    VARADDRESS.  */
 
 void
-staticpro (varaddress)
-     Lisp_Object *varaddress;
+staticpro (Lisp_Object *varaddress)
 {
   staticvec[staticidx++] = varaddress;
   if (staticidx >= NSTATICS)
@@ -5026,7 +4914,7 @@ staticpro (varaddress)
 /* Temporarily prevent garbage collection.  */
 
 int
-inhibit_garbage_collection ()
+inhibit_garbage_collection (void)
 {
   int count = SPECPDL_INDEX ();
   int nbits = min (VALBITS, BITS_PER_INT);
@@ -5047,7 +4935,7 @@ Garbage collection happens automatically if you cons more than
   (USED-STRINGS . FREE-STRINGS))
 However, if there was overflow in pure space, `garbage-collect'
 returns nil, because real GC can't be done.  */)
-     ()
+  (void)
 {
   register struct specbinding *bind;
   struct catchtag *catch;
@@ -5130,9 +5018,9 @@ returns nil, because real GC can't be done.  */)
          if (stack_copy)
            {
              if ((EMACS_INT) (&stack_top_variable - stack_bottom) > 0)
-               bcopy (stack_bottom, stack_copy, i);
+               memcpy (stack_copy, stack_bottom, i);
              else
-               bcopy (&stack_top_variable, stack_copy, i);
+               memcpy (stack_copy, &stack_top_variable, i);
            }
        }
     }
@@ -5165,7 +5053,7 @@ returns nil, because real GC can't be done.  */)
 
 #ifdef USE_GTK
   {
-    extern void xg_mark_data ();
+    extern void xg_mark_data (void);
     xg_mark_data ();
   }
 #endif
@@ -5358,8 +5246,7 @@ returns nil, because real GC can't be done.  */)
    only interesting objects referenced from glyphs are strings.  */
 
 static void
-mark_glyph_matrix (matrix)
-     struct glyph_matrix *matrix;
+mark_glyph_matrix (struct glyph_matrix *matrix)
 {
   struct glyph_row *row = matrix->rows;
   struct glyph_row *end = row + matrix->nrows;
@@ -5385,8 +5272,7 @@ mark_glyph_matrix (matrix)
 /* Mark Lisp faces in the face cache C.  */
 
 static void
-mark_face_cache (c)
-     struct face_cache *c;
+mark_face_cache (struct face_cache *c)
 {
   if (c)
     {
@@ -5421,8 +5307,7 @@ int last_marked_index;
 static int mark_object_loop_halt;
 
 static void
-mark_vectorlike (ptr)
-     struct Lisp_Vector *ptr;
+mark_vectorlike (struct Lisp_Vector *ptr)
 {
   register EMACS_INT size = ptr->size;
   register int i;
@@ -5445,8 +5330,7 @@ mark_vectorlike (ptr)
    symbols.  */
 
 static void
-mark_char_table (ptr)
-     struct Lisp_Vector *ptr;
+mark_char_table (struct Lisp_Vector *ptr)
 {
   register EMACS_INT size = ptr->size & PSEUDOVECTOR_SIZE_MASK;
   register int i;
@@ -5470,8 +5354,7 @@ mark_char_table (ptr)
 }
 
 void
-mark_object (arg)
-     Lisp_Object arg;
+mark_object (Lisp_Object arg)
 {
   register Lisp_Object obj = arg;
 #ifdef GC_CHECK_MARKED_OBJECTS
@@ -5780,8 +5663,7 @@ mark_object (arg)
 /* Mark the pointers in a buffer structure.  */
 
 static void
-mark_buffer (buf)
-     Lisp_Object buf;
+mark_buffer (Lisp_Object buf)
 {
   register struct buffer *buffer = XBUFFER (buf);
   register Lisp_Object *ptr, tmp;
@@ -5848,8 +5730,7 @@ mark_terminals (void)
    either marked or does not need to be marked to survive.  */
 
 int
-survives_gc_p (obj)
-     Lisp_Object obj;
+survives_gc_p (Lisp_Object obj)
 {
   int survives_p;
 
@@ -5895,7 +5776,7 @@ survives_gc_p (obj)
 /* Sweep: find all structures not marked, and free them. */
 
 static void
-gc_sweep ()
+gc_sweep (void)
 {
   /* Remove or mark entries in weak hash tables.
      This must be done before any object is unmarked.  */
@@ -6271,7 +6152,7 @@ DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, 0,
        doc: /* Return the address of the last byte Emacs has allocated, divided by 1024.
 This may be helpful in debugging Emacs's memory usage.
 We divide the value by 1024 to make sure it fits in a Lisp integer.  */)
-     ()
+  (void)
 {
   Lisp_Object end;
 
@@ -6293,7 +6174,7 @@ objects consed.
 MISCS include overlays, markers, and some internal types.
 Frames, windows, buffers, and subprocesses count as vectors
   (but the contents of a buffer's text do not count here).  */)
-     ()
+  (void)
 {
   Lisp_Object consed[8];
 
@@ -6312,10 +6193,7 @@ Frames, windows, buffers, and subprocesses count as vectors
 int suppress_checking;
 
 void
-die (msg, file, line)
-     const char *msg;
-     const char *file;
-     int line;
+die (const char *msg, const char *file, int line)
 {
   fprintf (stderr, "\r\n%s:%d: Emacs fatal error: %s\r\n",
           file, line, msg);
@@ -6325,7 +6203,7 @@ die (msg, file, line)
 /* Initialization */
 
 void
-init_alloc_once ()
+init_alloc_once (void)
 {
   /* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet!  */
   purebeg = PUREBEG;
@@ -6380,7 +6258,7 @@ init_alloc_once ()
 }
 
 void
-init_alloc ()
+init_alloc (void)
 {
   gcprolist = 0;
   byte_stack_list = 0;
@@ -6394,7 +6272,7 @@ init_alloc ()
 }
 
 void
-syms_of_alloc ()
+syms_of_alloc (void)
 {
   DEFVAR_INT ("gc-cons-threshold", &gc_cons_threshold,
              doc: /* *Number of bytes of consing between garbage collections.