copy-acl: ignore ENOTSUP on HP-UX
[gnulib.git] / lib / areadlink.c
index b506eb8..1c82c55 100644 (file)
@@ -1,7 +1,7 @@
 /* areadlink.c -- readlink wrapper to return the link name in malloc'd storage
    Unlike xreadlink and xreadlink_with_size, don't ever call exit.
 
-   Copyright (C) 2001, 2003-2007, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
 # 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;
+        }
     }
 }