From 379d4ec4970113f6b0945fe77c01834eea837868 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sat, 2 Feb 2002 09:49:35 +0000 Subject: Update. 2002-02-02 Ulrich Drepper * 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. --- sysdeps/generic/dl-environ.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'sysdeps/generic/dl-environ.c') 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; } -- cgit 1.4.1