Module Name:    src
Committed By:   enami
Date:           Tue Nov  2 03:44:05 UTC 2010

Modified Files:
        src/lib/libc/stdlib: getenv.c

Log Message:
- Simplify the code
- Reword the comment.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/lib/libc/stdlib/getenv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/stdlib/getenv.c
diff -u src/lib/libc/stdlib/getenv.c:1.27 src/lib/libc/stdlib/getenv.c:1.28
--- src/lib/libc/stdlib/getenv.c:1.27	Mon Nov  1 02:41:27 2010
+++ src/lib/libc/stdlib/getenv.c	Tue Nov  2 03:44:05 2010
@@ -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)

Reply via email to