bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [3/4] areadlink, relocwrapper interaction with replacement functions


From: Bruno Haible
Subject: Re: [3/4] areadlink, relocwrapper interaction with replacement functions
Date: Wed, 9 Jun 2010 12:52:58 +0200
User-agent: KMail/1.9.9

Here's the proposed patch for doing the same with 'areadlink'.

Jim, this is limited to the modules included by the 'relocwrapper' program.
I have no intent to avoid the 'malloc-posix' and 'realloc-posix' modules in
general. OK to apply?


2010-06-09  Bruno Haible  <address@hidden>

        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 <address@hidden>.

--- lib/areadlink.c.orig        Wed Jun  9 12:48:34 2010
+++ lib/areadlink.c     Wed Jun  9 12:42:14 2010
@@ -35,6 +35,10 @@
 # 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 @@
             {
               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 @@
         }
       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;
+        }
     }
 }
--- modules/areadlink.orig      Wed Jun  9 12:48:34 2010
+++ modules/areadlink   Wed Jun  9 12:42:14 2010
@@ -6,7 +6,6 @@
 lib/areadlink.c
 
 Depends-on:
-malloc-posix
 readlink
 ssize_t
 stdint



reply via email to

[Prev in Thread] Current Thread [Next in Thread]