about summary refs log tree commit diff
path: root/sysdeps/generic/setenv.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-05-15 15:28:15 +0000
committerUlrich Drepper <drepper@redhat.com>1998-05-15 15:28:15 +0000
commitcb37d8429a6d2da1e76e4e9ff22c51939ef56a6d (patch)
treef11a1eb5efac57602011a4f41ca0af0f1e6b843b /sysdeps/generic/setenv.c
parentb17277cfa29eee1b76fcaa18f2d4bb21c1567d6c (diff)
downloadglibc-cb37d8429a6d2da1e76e4e9ff22c51939ef56a6d.tar.gz
glibc-cb37d8429a6d2da1e76e4e9ff22c51939ef56a6d.tar.xz
glibc-cb37d8429a6d2da1e76e4e9ff22c51939ef56a6d.zip
Update.
1998-05-15  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/generic/setenv.c (setenv): Remove optimization for
	overwriting existing values if it fits.
Diffstat (limited to 'sysdeps/generic/setenv.c')
-rw-r--r--sysdeps/generic/setenv.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/sysdeps/generic/setenv.c b/sysdeps/generic/setenv.c
index baae4c59b2..22ea7e551f 100644
--- a/sysdeps/generic/setenv.c
+++ b/sysdeps/generic/setenv.c
@@ -187,50 +187,44 @@ setenv (name, value, replace)
   else if (replace)
     {
       size_t len = strlen (*ep);
-      if (len + 1 < namelen + 1 + vallen)
-	{
-	  char *new_value;
-	  char *np;
+      char *new_value;
+      char *np;
 
-	  /* The existing string is too short; malloc a new one.  */
+      /* The existing string is too short; malloc a new one.  */
 #ifdef USE_TSEARCH
-	  new_value = alloca (namelen + 1 + vallen);
+      new_value = alloca (namelen + 1 + vallen);
 # ifdef _LIBC
-	  __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
-		     value, vallen);
+      __mempcpy (__mempcpy (__mempcpy (new_value, name, namelen), "=", 1),
+		 value, vallen);
 # else
-	  memcpy (new_value, name, namelen);
-	  new_value[namelen] = '=';
-	  memcpy (&new_value[namelen + 1], value, vallen);
+      memcpy (new_value, name, namelen);
+      new_value[namelen] = '=';
+      memcpy (&new_value[namelen + 1], value, vallen);
 # endif
 
-	  np = KNOWN_VALUE (new_value);
-	  if (np == NULL)
+      np = KNOWN_VALUE (new_value);
+      if (np == NULL)
 #endif
+	{
+	  np = malloc (namelen + 1 + vallen);
+	  if (np == NULL)
 	    {
-	      np = malloc (namelen + 1 + vallen);
-	      if (np == NULL)
-		{
-		  UNLOCK;
-		  return -1;
-		}
+	      UNLOCK;
+	      return -1;
+	    }
 
 #ifdef USE_TSEARCH
-	      memcpy (np, new_value, namelen + 1 + vallen);
+	  memcpy (np, new_value, namelen + 1 + vallen);
 #else
-	      memcpy (np, name, namelen);
-	      np[namelen] = '=';
-	      memcpy (&np[namelen + 1], value, vallen);
+	  memcpy (np, name, namelen);
+	  np[namelen] = '=';
+	  memcpy (&np[namelen + 1], value, vallen);
 #endif
-	    }
-
-	  /* Keep the old value around.  */
-	  STORE_VALUE (*ep);
-	  *ep = np;
 	}
-      else
-	/* Overwrite the value part of the old value.  */
-	memcpy (&(*ep)[namelen + 1], value, vallen);
+
+      /* Keep the old value around.  */
+      STORE_VALUE (*ep);
+      *ep = np;
     }
 
   UNLOCK;