Comparing only the keys produces the same result as comparing keys and
value. The latter saves two invocations of each `strndup` and `free`.
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
tests/commandhelper.c | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/tests/commandhelper.c b/tests/commandhelper.c
index 2b937979c0..05e3879688 100644
--- a/tests/commandhelper.c
+++ b/tests/commandhelper.c
@@ -39,22 +39,7 @@ static int envsort(const void *a, const void *b)
{
const char *const*astrptr = a;
const char *const*bstrptr = b;
- const char *astr = *astrptr;
- const char *bstr = *bstrptr;
- char *aeq = strchr(astr, '=');
- char *beq = strchr(bstr, '=');
- char *akey;
- char *bkey;
- int ret;
-
- if (!(akey = strndup(astr, aeq - astr)))
- abort();
- if (!(bkey = strndup(bstr, beq - bstr)))
- abort();
- ret = strcmp(akey, bkey);
- free(akey);
- free(bkey);
- return ret;
+ return strcmp(*astrptr, *bstrptr);
}
int main(int argc, char **argv) {
--
2.26.2