* fakemail.c (xmalloc, xreallc): Use standard C prototypes
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 16 Apr 2011 21:13:07 +0000 (14:13 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 16 Apr 2011 21:13:07 +0000 (14:13 -0700)
with void *.  This avoids warnings about pointer casts.

lib-src/ChangeLog
lib-src/fakemail.c

index 07d51ff..2e3c62d 100644 (file)
@@ -1,5 +1,8 @@
 2011-04-16  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * fakemail.c (xmalloc, xreallc): Use standard C prototypes
+       with void *.  This avoids warnings about pointer casts.
+
        * emacsclient.c (main): Don't use uninitialized var.
        (IS_ANY_SEP): Remove; unused.
        (get_current_dir_name): Add an extern decl.
index 940d621..4355121 100644 (file)
@@ -178,20 +178,20 @@ fatal (const char *s1)
 
 /* Like malloc but get fatal error if memory is exhausted.  */
 
-static long *
-xmalloc (int size)
+static void *
+xmalloc (size_t size)
 {
-  long *result = (long *) malloc (((unsigned) size));
-  if (result == ((long *) NULL))
+  void *result = malloc (size);
+  if (! result)
     fatal ("virtual memory exhausted");
   return result;
 }
 
-static long *
-xrealloc (long int *ptr, int size)
+static void *
+xrealloc (void *ptr, size_t size)
 {
-  long *result = (long *) realloc (ptr, ((unsigned) size));
-  if (result == ((long *) NULL))
+  void *result = realloc (ptr, size);
+  if (! result)
     fatal ("virtual memory exhausted");
   return result;
 }
@@ -221,7 +221,7 @@ readline (struct linebuffer *linebuffer, FILE *stream)
       if (p == end)
        {
          linebuffer->size *= 2;
-         buffer = ((char *) xrealloc ((long *)buffer, linebuffer->size));
+         buffer = (char *) xrealloc (buffer, linebuffer->size);
          p = buffer + (p - linebuffer->buffer);
          end = buffer + linebuffer->size;
          linebuffer->buffer = buffer;