changeset 14537:10946c7debf8

careadlinkat: rename members to avoid problem * lib/allocator.h (struct allocator): Rename members from malloc/realloc to allocate/reallocate, to avoid problems if malloc and realloc are #define'd. Reported by Eric Blake in <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00091.html>. * lib/careadlinkat.c (careadlinkat): Adjust to renaming. careadlinkat: fix compilation error on mingw
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 08 Apr 2011 10:41:30 -0700
parents 388a32f36b2c
children cd02b552d886
files ChangeLog lib/allocator.h lib/careadlinkat.c
diffstat 3 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-04-08  Paul Eggert  <eggert@cs.ucla.edu>
+
+	careadlinkat: rename members to avoid problem
+	* lib/allocator.h (struct allocator): Rename members from
+	malloc/realloc to allocate/reallocate, to avoid problems if malloc
+	and realloc are #define'd.  Reported by Eric Blake in
+	<http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00091.html>.
+	* lib/careadlinkat.c (careadlinkat): Adjust to renaming.
+
 2011-04-08  Eric Blake  <eblake@redhat.com>
 
 	nonblocking: reduce dependency
--- a/lib/allocator.h
+++ b/lib/allocator.h
@@ -30,16 +30,16 @@
      attributes do not work with pointers to functions.  See
      <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00007.html>.  */
 
-  /* Call MALLOC to allocate memory, like 'malloc'.  On failure MALLOC
+  /* Call ALLOCATE to allocate memory, like 'malloc'.  On failure ALLOCATE
      should return NULL, though not necessarily set errno.  When given
      a zero size it may return NULL even if successful.  */
-  void *(*malloc) (size_t);
+  void *(*allocate) (size_t);
 
-  /* If nonnull, call REALLOC to reallocate memory, like 'realloc'.
-     On failure REALLOC should return NULL, though not necessarily set
+  /* If nonnull, call REALLOCATE to reallocate memory, like 'realloc'.
+     On failure REALLOCATE should return NULL, though not necessarily set
      errno.  When given a zero size it may return NULL even if
      successful.  */
-  void *(*realloc) (void *, size_t);
+  void *(*reallocate) (void *, size_t);
 
   /* Call FREE to free memory, like 'free'.  */
   void (*free) (void *);
--- a/lib/careadlinkat.c
+++ b/lib/careadlinkat.c
@@ -133,16 +133,16 @@
 
           if (buf == stack_buf)
             {
-              char *b = (char *) alloc->malloc (link_size);
+              char *b = (char *) alloc->allocate (link_size);
               if (! b)
                 break;
               memcpy (b, buf, link_size);
               buf = b;
             }
-          else if (link_size < buf_size && buf != buffer && alloc->realloc)
+          else if (link_size < buf_size && buf != buffer && alloc->reallocate)
             {
               /* Shrink BUF before returning it.  */
-              char *b = (char *) alloc->realloc (buf, link_size);
+              char *b = (char *) alloc->reallocate (buf, link_size);
               if (b)
                 buf = b;
             }
@@ -159,7 +159,7 @@
         buf_size = buf_size_max;
       else
         break;
-      buf = (char *) alloc->malloc (buf_size);
+      buf = (char *) alloc->allocate (buf_size);
     }
   while (buf);