Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/stdlib - Simplify the code
details: https://anonhg.NetBSD.org/src/rev/38036c735cf9
branches: trunk
changeset: 758316:38036c735cf9
user: enami <enami%NetBSD.org@localhost>
date: Tue Nov 02 03:44:05 2010 +0000
description:
- Simplify the code
- Reword the comment.
diffstat:
lib/libc/stdlib/getenv.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diffs (32 lines):
diff -r 132290af10ea -r 38036c735cf9 lib/libc/stdlib/getenv.c
--- a/lib/libc/stdlib/getenv.c Mon Nov 01 19:00:08 2010 +0000
+++ b/lib/libc/stdlib/getenv.c Tue Nov 02 03:44:05 2010 +0000
@@ -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 @@
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)
Home |
Main Index |
Thread Index |
Old Index