X-Git-Url: https://git.cworth.org/git?p=tar;a=blobdiff_plain;f=gnu%2Fsetenv.c;fp=gnu%2Fsetenv.c;h=a1c1df84ede23f97308efeca13b4f5d094a78c73;hp=d4670e5c99e8f1dffad18acc12acff60cf339833;hb=b414e25de8ca49d7567a92c203d431383ec57c83;hpb=29ece34f44a27750bbfd76154ad9882580453dc7 diff --git a/gnu/setenv.c b/gnu/setenv.c index d4670e5..a1c1df8 100644 --- a/gnu/setenv.c +++ b/gnu/setenv.c @@ -66,6 +66,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 @@ -114,8 +118,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; @@ -149,6 +153,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; } @@ -251,7 +258,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