Avoid relocwrapper link errors due to gnulib replacement functions. 20100610040508/gnulib 20100611040505/gnulib 20100612040503/gnulib 20100613040502/gnulib 20100614040504/gnulib 20100615040506/gnulib 20100616040508/gnulib 99/gnulib
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 d8cafae3ba7c57ad4f34d6f4784b0911eab5142e..57d9e2c981d78b7c6cc1977cc5c2525c10297d7c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+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.
index b0db4200cb2e7e77b2cc71ecd34870bbd93fb828..1c82c55d25fd8c67f21ef8c0be28eec4f403dbca 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 199c77fa2f4a437b5831e34184dc12682dba4e76..316626994fd4963a413b1b6f59529d7601a0e666 100644 (file)
@@ -6,7 +6,6 @@ lib/areadlink.h
 lib/areadlink.c
 
 Depends-on:
-malloc-posix
 readlink
 ssize_t
 stdint