Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libutil Add a missing free() of a temporary buffer.
details: https://anonhg.NetBSD.org/src/rev/5d58fd83b658
branches: trunk
changeset: 481967:5d58fd83b658
user: mjl <mjl%NetBSD.org@localhost>
date: Thu Feb 10 20:52:54 2000 +0000
description:
Add a missing free() of a temporary buffer.
Add "unlimited" as synonym for "inf" and "infinity" for the
benefit of FreeBSD users.
Factor out the comparison w/ "infinity" in a isinfinite() function.
diffstat:
lib/libutil/login_cap.c | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diffs (78 lines):
diff -r 638ac8389b47 -r 5d58fd83b658 lib/libutil/login_cap.c
--- a/lib/libutil/login_cap.c Thu Feb 10 18:20:56 2000 +0000
+++ b/lib/libutil/login_cap.c Thu Feb 10 20:52:54 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: login_cap.c,v 1.4 2000/02/04 02:17:16 mjl Exp $ */
+/* $NetBSD: login_cap.c,v 1.5 2000/02/10 20:52:54 mjl Exp $ */
/*-
* Copyright (c) 1995,1997 Berkeley Software Design, Inc. All rights reserved.
@@ -61,6 +61,7 @@
static u_quad_t strtosize __P((char *, char **, int));
static int gsetrl __P((login_cap_t *, int, char *, int type));
static int setuserenv __P((login_cap_t *));
+static int isinfinite __P((const char *));
login_cap_t *
login_getclass(class)
@@ -196,7 +197,7 @@
return (e);
}
- if (strcasecmp(res, "infinity") == 0)
+ if (isinfinite(res))
return (RLIM_INFINITY);
errno = 0;
@@ -276,7 +277,7 @@
return (e);
}
- if (strcasecmp(res, "infinity") == 0)
+ if (isinfinite(res))
return (RLIM_INFINITY);
errno = 0;
@@ -491,6 +492,7 @@
}
}
+ free(res);
return 0;
}
@@ -739,7 +741,7 @@
char **endptr;
int radix;
{
- if (strcasecmp(str, "infinity") == 0 || strcasecmp(str, "inf") == 0) {
+ if (isinfinite(str)) {
if (endptr)
*endptr = str + strlen(str);
return ((u_quad_t)RLIM_INFINITY);
@@ -747,6 +749,25 @@
return (strtosize(str, endptr, radix));
}
+static int
+isinfinite(const char *s)
+{
+ static const char *infs[] = {
+ "infinity",
+ "inf",
+ "unlimited",
+ "unlimit",
+ NULL
+ };
+ const char **i;
+
+ for(i = infs; *i; i++) {
+ if (!strcasecmp(s, *i))
+ return 1;
+ }
+ return 0;
+}
+
static u_quad_t
multiply(n1, n2)
u_quad_t n1;
Home |
Main Index |
Thread Index |
Old Index