From: Paul Eggert Date: Sat, 16 Apr 2011 21:13:07 +0000 (-0700) Subject: * fakemail.c (xmalloc, xreallc): Use standard C prototypes X-Git-Tag: emacs-pretest-24.0.90~104^2~275^2~268^2~18 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=cd52b2441e95f407c0332534ae1997023fe62461;p=emacs.git * fakemail.c (xmalloc, xreallc): Use standard C prototypes with void *. This avoids warnings about pointer casts. --- diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 07d51ff14bd..2e3c62d414e 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,5 +1,8 @@ 2011-04-16 Paul Eggert + * 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. diff --git a/lib-src/fakemail.c b/lib-src/fakemail.c index 940d6219425..435512125ff 100644 --- a/lib-src/fakemail.c +++ b/lib-src/fakemail.c @@ -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;