about summary refs log tree commit diff
path: root/sysdeps/generic
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-02-02 09:49:35 +0000
committerUlrich Drepper <drepper@redhat.com>2002-02-02 09:49:35 +0000
commit379d4ec4970113f6b0945fe77c01834eea837868 (patch)
treec59113a0971949456a81b4935c874030b67dc02c /sysdeps/generic
parente0f418860056d884a03be8344eeeb60759ea86e2 (diff)
downloadglibc-379d4ec4970113f6b0945fe77c01834eea837868.tar.gz
glibc-379d4ec4970113f6b0945fe77c01834eea837868.tar.xz
glibc-379d4ec4970113f6b0945fe77c01834eea837868.zip
Update.
2002-02-02  Ulrich Drepper  <drepper@redhat.com>

	* sysdeps/generic/dl-environ.c (unsetenv): Optimize.  Don't use
	strncmp.
	* elf/dl-load.c (is_dst): Optimize.  Don't call strncmp twice.
	* elf/rtld.c (process_dl_debug): Optimize. Avoid calls to strncmp,
	strspn, and strcspn.
	(process_envvars): Don't use strcspn.

	* elf/dl-load.c (_dl_dst_count): Fix possible endless loop.
	(_dl_dst_substitute): Likewise.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/dl-environ.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/sysdeps/generic/dl-environ.c b/sysdeps/generic/dl-environ.c
index 7a3da0c4b5..e13bb5d792 100644
--- a/sysdeps/generic/dl-environ.c
+++ b/sysdeps/generic/dl-environ.c
@@ -1,5 +1,5 @@
 /* Environment handling for dynamic loader.
-   Copyright (C) 1995-1998, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1995-1998, 2000, 2001, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -53,23 +53,30 @@ _dl_next_ld_env_entry (char ***position)
 int
 unsetenv (const char *name)
 {
-  const size_t len = strlen (name);
   char **ep;
 
   ep = __environ;
   while (*ep != NULL)
-    if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
-      {
-	/* Found it.  Remove this pointer by moving later ones back.  */
-	char **dp = ep;
-
-	do
-	  dp[0] = dp[1];
-	while (*dp++);
-	/* Continue the loop in case NAME appears again.  */
-      }
-    else
-      ++ep;
+    {
+      size_t cnt;
+
+      while ((*ep)[cnt] == name[cnt] && name[cnt] != '\0')
+	++cnt;
+
+      if ((*ep)[cnt] == '=')
+	{
+	  /* Found it.  Remove this pointer by moving later ones to
+	     the front.  */
+	  char **dp = ep;
+
+	  do
+	    dp[0] = dp[1];
+	  while (*dp++);
+	  /* Continue the loop in case NAME appears again.  */
+	}
+      else
+	++ep;
+    }
 
   return 0;
 }