diff options
author | pfg <pfg@FreeBSD.org> | 2017-03-15 15:33:32 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2017-03-15 15:33:32 +0000 |
commit | 466bdf25f48f01fdeff163183f0be4fa531d8545 (patch) | |
tree | a0682cafacc7bec83d40c16a438196cb0b1e1dab /lib/libc/stdlib/getenv.c | |
parent | e3e3811f31a3bd1bc1bc938e1194516e56b666db (diff) | |
download | FreeBSD-src-466bdf25f48f01fdeff163183f0be4fa531d8545.zip FreeBSD-src-466bdf25f48f01fdeff163183f0be4fa531d8545.tar.gz |
MFC r315095, r315096, r315097, r315187:
libc: small cleanups.
Rename nitems to numitems: it shares the anme with an existing macro in
sys/params.h. Also initialize the value later which avoids asigning the
value if we exit early.
Unsign setlen: it is local and will never be negative. Having one more bit
for growth is beneficial and it avoids a cast when it's going to be used
for allocation.
Remove unused initialization: "num" is properly defined before use.
Let calloc(3) do the multiplication.
Diffstat (limited to 'lib/libc/stdlib/getenv.c')
-rw-r--r-- | lib/libc/stdlib/getenv.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c index 8451103..35e24a4 100644 --- a/lib/libc/stdlib/getenv.c +++ b/lib/libc/stdlib/getenv.c @@ -342,7 +342,7 @@ __build_env(void) envVarsSize = envVarsTotal * 2; /* Create new environment. */ - envVars = calloc(1, sizeof (*envVars) * envVarsSize); + envVars = calloc(envVarsSize, sizeof(*envVars)); if (envVars == NULL) goto Failure; |