summaryrefslogtreecommitdiff
path: root/lib/libc/stdlib
diff options
context:
space:
mode:
authorenami <enami@NetBSD.org>2010-11-02 03:44:05 +0000
committerenami <enami@NetBSD.org>2010-11-02 03:44:05 +0000
commitb447d18264ebbd5cd465540090b9c1880fe9942a (patch)
treed381c805a68d3786a49a725ee60818671f251ee7 /lib/libc/stdlib
parent4e6c889e19ce1fa17f771ed934060b7890a2cb90 (diff)
- Simplify the code
- Reword the comment.
Diffstat (limited to 'lib/libc/stdlib')
-rw-r--r--lib/libc/stdlib/getenv.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c
index 6dbf299a4e0..fda3e2ac693 100644
--- a/lib/libc/stdlib/getenv.c
+++ b/lib/libc/stdlib/getenv.c
@@ -1,4 +1,4 @@
-/* $NetBSD: getenv.c,v 1.27 2010/11/01 02:41:27 enami Exp $ */
+/* $NetBSD: getenv.c,v 1.28 2010/11/02 03:44:05 enami Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)getenv.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: getenv.c,v 1.27 2010/11/01 02:41:27 enami Exp $");
+__RCSID("$NetBSD: getenv.c,v 1.28 2010/11/02 03:44:05 enami Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -119,10 +119,10 @@ __allocenv(int offset)
if (required_len <= environ_malloced_len && saveenv == environ)
return 0;
- /* Make sure we at least double the size of the arrays. */
- new_len = environ_malloced_len >= 16 ? environ_malloced_len : 16;
+ /* Double the size of the arrays until we meet the requirement. */
+ new_len = environ_malloced_len ? environ_malloced_len : 16;
while (new_len < required_len)
- new_len = new_len << 1;
+ new_len <<= 1;
if (saveenv == environ) { /* just increase size */
if ((p = realloc(saveenv, new_len * sizeof(*p))) == NULL)