From 7a6955f7b5a90dbd30cb88217406c49c23ead9d1 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 8 Apr 2011 10:41:30 -0700 Subject: [PATCH] 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 . * lib/careadlinkat.c (careadlinkat): Adjust to renaming. careadlinkat: fix compilation error on mingw --- ChangeLog | 9 +++++++++ lib/allocator.h | 10 +++++----- lib/careadlinkat.c | 8 ++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 099dbd7abf..c7e4c92804 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-04-08 Paul Eggert + + 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 + . + * lib/careadlinkat.c (careadlinkat): Adjust to renaming. + 2011-04-08 Eric Blake nonblocking: reduce dependency diff --git a/lib/allocator.h b/lib/allocator.h index 4ac863b224..e30732b605 100644 --- a/lib/allocator.h +++ b/lib/allocator.h @@ -30,16 +30,16 @@ struct allocator attributes do not work with pointers to functions. See . */ - /* 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 *); diff --git a/lib/careadlinkat.c b/lib/careadlinkat.c index eb2e009e99..0b54b1dfd7 100644 --- a/lib/careadlinkat.c +++ b/lib/careadlinkat.c @@ -133,16 +133,16 @@ careadlinkat (int fd, char const *filename, 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 @@ careadlinkat (int fd, char const *filename, buf_size = buf_size_max; else break; - buf = (char *) alloc->malloc (buf_size); + buf = (char *) alloc->allocate (buf_size); } while (buf); -- 2.30.2