Avoid relocwrapper link errors due to gnulib replacement functions.
authorBruno Haible <bruno@clisp.org>
Wed, 9 Jun 2010 13:30:40 +0000 (15:30 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 9 Jun 2010 13:30:40 +0000 (15:30 +0200)
ChangeLog
lib/areadlink.c
modules/areadlink

index d8cafae..57d9e2c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
 2010-06-09  Bruno Haible  <bruno@clisp.org>
 
        Avoid relocwrapper link errors due to gnulib replacement functions.
+       * lib/areadlink.c: Use the system's malloc, realloc functions.
+       (areadlink): Set errno to ENOMEM explicitly.
+       * modules/areadlink (Depends-on): Remove malloc-posix.
+       Reported by Ben Pfaff <blp@cs.stanford.edu>.
+
+2010-06-09  Bruno Haible  <bruno@clisp.org>
+
+       Avoid relocwrapper link errors due to gnulib replacement functions.
        * lib/canonicalize-lgpl.c: Use the system's malloc function.
        * lib/malloca.c: Likewise.
        * lib/relocatable.c: Likewise.
index b0db420..1c82c55 100644 (file)
 # define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
 #endif
 
+/* Use the system functions, not the gnulib overrides in this file.  */
+#undef malloc
+#undef realloc
+
 /* The initial buffer size for the link value.  A power of 2
    detects arithmetic overflow earlier, but is not required.  */
 enum {
@@ -85,8 +89,12 @@ areadlink (char const *filename)
             {
               buffer = (char *) malloc (link_length);
               if (buffer == NULL)
-                /* errno is ENOMEM.  */
-                return NULL;
+                {
+                  /* It's easier to set errno to ENOMEM than to rely on the
+                     'malloc-posix' gnulib module.  */
+                  errno = ENOMEM;
+                  return NULL;
+                }
               memcpy (buffer, initial_buf, link_length);
             }
           else
@@ -113,7 +121,11 @@ areadlink (char const *filename)
         }
       buffer = (char *) malloc (buf_size);
       if (buffer == NULL)
-        /* errno is ENOMEM.  */
-        return NULL;
+        {
+          /* It's easier to set errno to ENOMEM than to rely on the
+             'malloc-posix' gnulib module.  */
+          errno = ENOMEM;
+          return NULL;
+        }
     }
 }
index 199c77f..3166269 100644 (file)
@@ -6,7 +6,6 @@ lib/areadlink.h
 lib/areadlink.c
 
 Depends-on:
-malloc-posix
 readlink
 ssize_t
 stdint