Extend freadptr to return also the buffer size.
[gnulib.git] / lib / putenv.c
index 1d24a57..d0573c6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1997, 1998, 2000, 2003, 2004, 2005, 2006, 2007
+/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2008
    Free Software Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with the GNU C
 
 #include <config.h>
 
-/* undef putenv here, because some (e.g., Solaris 10) declare putenv in
-   with a non-const argument.  That would conflict with the declaration of
-   rpl_putenv below (due to the #define putenv rpl_putenv from config.h).  */
-#undef putenv
-int rpl_putenv (char const *);
+/* Specification.  */
+#include <stdlib.h>
 
 #include <stddef.h>
 
@@ -95,7 +92,7 @@ _unsetenv (const char *name)
 /* Put STRING, which is of the form "NAME=VALUE", in the environment.
    If STRING contains no `=', then remove STRING from the environment.  */
 int
-rpl_putenv (const char *string)
+putenv (char *string)
 {
   const char *const name_end = strchr (string, '=');
   register size_t size;
@@ -125,13 +122,12 @@ rpl_putenv (const char *string)
                     size * sizeof (char *));
       new_environ[size] = (char *) string;
       new_environ[size + 1] = NULL;
-      if (last_environ != NULL)
-       free (last_environ);
+      free (last_environ);
       last_environ = new_environ;
       environ = new_environ;
     }
   else
-    *ep = (char *) string;
+    *ep = string;
 
   return 0;
 }