X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=inline;f=lib%2Fsetenv.c;h=0a5f67dd044a8ee57c28025564798ae5d6fad6dc;hb=b94f2b3ac7049ef66bded4596431c453e3710209;hp=b4c55322907ce70864434e168e407476b409c929;hpb=b2e2010c7c902235b5efb5bd3c6529f61b093aa4;p=gnulib.git
diff --git a/lib/setenv.c b/lib/setenv.c
index b4c553229..0a5f67dd0 100644
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995-2003, 2005-2010 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2003, 2005-2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
This program is free software: you can redistribute it and/or modify
@@ -15,6 +15,7 @@
along with this program. If not, see . */
#if !_LIBC
+# define _GL_USE_STDLIB_ALLOC 1
# include
#endif
@@ -112,8 +113,8 @@ int
__add_to_environ (const char *name, const char *value, const char *combined,
int replace)
{
- register char **ep;
- register size_t size;
+ char **ep;
+ size_t size;
const size_t namelen = strlen (name);
const size_t vallen = value != NULL ? strlen (value) + 1 : 0;
@@ -147,6 +148,9 @@ __add_to_environ (const char *name, const char *value, const char *combined,
: realloc (last_environ, (size + 2) * sizeof (char *)));
if (new_environ == NULL)
{
+ /* It's easier to set errno to ENOMEM than to rely on the
+ 'malloc-posix' and 'realloc-posix' gnulib modules. */
+ __set_errno (ENOMEM);
UNLOCK;
return -1;
}
@@ -249,7 +253,7 @@ __add_to_environ (const char *name, const char *value, const char *combined,
if (np == NULL)
#endif
{
- np = malloc (namelen + 1 + vallen);
+ np = (char *) malloc (namelen + 1 + vallen);
if (np == NULL)
{
#if defined USE_TSEARCH && !defined _LIBC
@@ -346,6 +350,9 @@ weak_alias (__clearenv, clearenv)
#if HAVE_SETENV
# undef setenv
+# if !HAVE_DECL_SETENV
+extern int setenv (const char *, const char *, int);
+# endif
# define STREQ(a, b) (strcmp (a, b) == 0)
int