X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fsetenv.c;h=7c061925dd7ffb5034dece4eaf07472d6d43f62f;hb=fc492e92429a239ba32ffe14d3236685963818a3;hp=93a5ef94d8a70db1d3c05d29c5a57a756f5bd28d;hpb=6948250861edce048d7bb3c6b47d13fa3649905e;p=gnulib.git diff --git a/lib/setenv.c b/lib/setenv.c index 93a5ef94d..7c061925d 100644 --- a/lib/setenv.c +++ b/lib/setenv.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1992,1995-1999,2000-2003,2005-2009 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 @@ -64,6 +64,10 @@ __libc_lock_define_initialized (static, envlock) # define clearenv __clearenv # define tfind __tfind # define tsearch __tsearch +#else +/* Use the system functions, not the gnulib overrides in this file. */ +# undef malloc +# undef realloc #endif /* In the GNU C library implementation we try to be more clever and @@ -112,8 +116,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 +151,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 +256,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