summaryrefslogtreecommitdiff
path: root/usr.bin/rcs/co.c
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-05-28 23:16:32 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-05-28 23:16:32 +0000
commitf5bec20632160804d7afc99cd777eab2cf44d93c (patch)
tree9583c54b93155b6ee21e33ba8809df3ee673b53d /usr.bin/rcs/co.c
parentcb2c6487f607d253f80e48b75dfec26355db4bdd (diff)
Remove a lot of xstrdup() calls in getopt() loops, which are usually
unnecessary. These xstrdup() calls don't call xfree() before anyway, so if a flag is given multiple times memory leaks would have resulted. OK joris@
Diffstat (limited to 'usr.bin/rcs/co.c')
-rw-r--r--usr.bin/rcs/co.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c
index 5052024e0da..dd88f6adbcc 100644
--- a/usr.bin/rcs/co.c
+++ b/usr.bin/rcs/co.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: co.c,v 1.93 2006/05/27 08:12:29 ray Exp $ */
+/* $OpenBSD: co.c,v 1.94 2006/05/28 23:16:31 ray Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -36,25 +36,24 @@ static void checkout_err_nobranch(RCSFILE *, const char *, const char *,
int
checkout_main(int argc, char **argv)
{
- int fd, i, ch, flags, kflag, status, warg;
+ int fd, i, ch, flags, kflag, status;
RCSNUM *rev;
RCSFILE *file;
+ const char *author, *date, *state;
char fpath[MAXPATHLEN];
- char *author, *date, *rev_str, *username, *state;
+ char *rev_str, *username;
time_t rcs_mtime = -1;
- warg = flags = status = 0;
+ flags = status = 0;
kflag = RCS_KWEXP_ERR;
rev = RCS_HEAD_REV;
rev_str = NULL;
- state = NULL;
- author = NULL;
- date = NULL;
+ author = date = state = NULL;
while ((ch = rcs_getopt(argc, argv, CO_OPTSTRING)) != -1) {
switch (ch) {
case 'd':
- date = xstrdup(rcs_optarg);
+ date = rcs_optarg;
break;
case 'f':
rcs_setrevstr(&rev_str, rcs_optarg);
@@ -97,7 +96,7 @@ checkout_main(int argc, char **argv)
rcs_setrevstr(&rev_str, rcs_optarg);
break;
case 's':
- state = xstrdup(rcs_optarg);
+ state = rcs_optarg;
flags |= CO_STATE;
break;
case 'T':
@@ -119,10 +118,8 @@ checkout_main(int argc, char **argv)
if (rcs_optarg == NULL) {
if ((author = getlogin()) == NULL)
err(1, "getlogin");
- } else {
- author = xstrdup(rcs_optarg);
- warg = 1;
- }
+ } else
+ author = rcs_optarg;
flags |= CO_AUTHOR;
break;
case 'x':
@@ -209,15 +206,6 @@ checkout_main(int argc, char **argv)
rcs_close(file);
}
- if (author != NULL && warg)
- xfree(author);
-
- if (date != NULL)
- xfree(date);
-
- if (state != NULL)
- xfree(state);
-
return (status);
}