From 272d2e99c9f864ca28035a63fd5db0c47e6fdcf8 Mon Sep 17 00:00:00 2001 From: George Bosilca Date: Wed, 31 Jan 2007 15:58:51 +0000 Subject: [PATCH] Reorder the code. This commit was SVN r13393. --- opal/util/opal_environ.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/opal/util/opal_environ.c b/opal/util/opal_environ.c index 0f22c3587f..6cdca9e0b4 100644 --- a/opal/util/opal_environ.c +++ b/opal/util/opal_environ.c @@ -199,17 +199,17 @@ int opal_unsetenv(const char *name, char ***env) found = false; for (i = 0; (*env)[i] != NULL; ++i) { - if (found) { - (*env)[i] = (*env)[i + 1]; - } else if (0 == strncmp((*env)[i], compare, len)) { + if (0 != strncmp((*env)[i], compare, len)) + continue; #if !defined(__WINDOWS__) - if (environ != *env) { - free((*env)[i]); - } -#endif - (*env)[i] = (*env)[i + 1]; - found = true; + if (environ != *env) { + free((*env)[i]); } +#endif + for (; (*env)[i] != NULL; ++i) + (*env)[i] = (*env)[i + 1]; + found = true; + break; } free(compare); @@ -217,3 +217,4 @@ int opal_unsetenv(const char *name, char ***env) return (found) ? OPAL_SUCCESS : OPAL_ERR_NOT_FOUND; } +