summaryrefslogtreecommitdiff
path: root/usr.bin/rcs
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/rcs')
-rw-r--r--usr.bin/rcs/Makefile6
-rw-r--r--usr.bin/rcs/ci.c43
-rw-r--r--usr.bin/rcs/co.c16
-rw-r--r--usr.bin/rcs/rcsclean.c6
-rw-r--r--usr.bin/rcs/rcsmerge.c4
-rw-r--r--usr.bin/rcs/rcsprog.c19
-rw-r--r--usr.bin/rcs/rcsprog.h4
7 files changed, 36 insertions, 62 deletions
diff --git a/usr.bin/rcs/Makefile b/usr.bin/rcs/Makefile
index 3d4f6b5b4f4..22183256359 100644
--- a/usr.bin/rcs/Makefile
+++ b/usr.bin/rcs/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.25 2005/12/01 09:35:59 xsa Exp $
+# $OpenBSD: Makefile,v 1.26 2005/12/10 20:27:46 joris Exp $
.PATH: ${.CURDIR}/../cvs
@@ -7,7 +7,9 @@ MAN= ci.1 co.1 ident.1 rcs.1 rcsclean.1 rcsdiff.1 rcsmerge.1 rlog.1 \
rcsintro.7
SRCS= ci.c co.c ident.c rcsclean.c rcsdiff.c rcsmerge.c rcsprog.c rlog.c \
- buf.c date.y diff.c diff3.c log.c rcs.c rcsnum.c util.c
+ buf.c date.y diff.c diff3.c fatal.c log.c rcs.c rcsnum.c util.c \
+ xmalloc.c
+
CPPFLAGS+=-I${.CURDIR}/../cvs -DRCSPROG
LINKS= ${BINDIR}/rcs ${BINDIR}/ci ${BINDIR}/rcs ${BINDIR}/co \
diff --git a/usr.bin/rcs/ci.c b/usr.bin/rcs/ci.c
index 120f8f08228..8b4e01465ee 100644
--- a/usr.bin/rcs/ci.c
+++ b/usr.bin/rcs/ci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ci.c,v 1.83 2005/12/09 04:27:01 joris Exp $ */
+/* $OpenBSD: ci.c,v 1.84 2005/12/10 20:27:46 joris Exp $ */
/*
* Copyright (c) 2005 Niall O'Higgins <niallo@openbsd.org>
* All rights reserved.
@@ -154,10 +154,7 @@ checkin_main(int argc, char **argv)
pb.flags &= ~INTERACTIVE;
break;
case 'N':
- if ((pb.symbol = strdup(rcs_optarg)) == NULL) {
- cvs_log(LP_ERRNO, "out of memory");
- exit(1);
- }
+ pb.symbol = xstrdup(rcs_optarg);
if (rcs_sym_check(pb.symbol) != 1) {
cvs_log(LP_ERR, "invalid symbol `%s'",
pb.symbol);
@@ -166,10 +163,7 @@ checkin_main(int argc, char **argv)
pb.flags |= CI_SYMFORCE;
break;
case 'n':
- if ((pb.symbol = strdup(rcs_optarg)) == NULL) {
- cvs_log(LP_ERRNO, "out of memory");
- exit(1);
- }
+ pb.symbol = xstrdup(rcs_optarg);
if (rcs_sym_check(pb.symbol) != 1) {
cvs_log(LP_ERR, "invalid symbol `%s'",
pb.symbol);
@@ -195,10 +189,7 @@ checkin_main(int argc, char **argv)
pb.flags |= PRESERVETIME;
break;
case 't':
- if ((pb.description = strdup(rcs_optarg)) == NULL) {
- cvs_log(LP_ERRNO, "out of memory");
- exit(1);
- }
+ pb.description = xstrdup(rcs_optarg);
break;
case 'u':
rcs_set_rev(rcs_optarg, &pb.newrev);
@@ -208,10 +199,7 @@ checkin_main(int argc, char **argv)
printf("%s\n", rcs_version);
exit(0);
case 'w':
- if ((pb.author = strdup(rcs_optarg)) == NULL) {
- cvs_log(LP_ERRNO, "out of memory");
- exit(1);
- }
+ pb.author = xstrdup(rcs_optarg);
break;
case 'x':
rcs_suffixes = rcs_optarg;
@@ -271,7 +259,7 @@ checkin_main(int argc, char **argv)
continue;
}
strlcpy(pb.fpath, fpath, sizeof(pb.fpath));
- free(fpath);
+ xfree(fpath);
}
pb.file = rcs_open(pb.fpath, pb.openflags, pb.fmode);
@@ -558,8 +546,8 @@ checkin_update(struct checkin_params *pb)
if (pb->state != NULL)
(void)rcs_state_set(pb->file, pb->newrev, pb->state);
- free(pb->deltatext);
- free(filec);
+ xfree(pb->deltatext);
+ xfree(filec);
(void)unlink(pb->filename);
/* Do checkout if -u or -l are specified. */
@@ -572,7 +560,7 @@ checkin_update(struct checkin_params *pb)
rcs_close(pb->file);
if (pb->flags & INTERACTIVE) {
- free(pb->rcs_msg);
+ xfree(pb->rcs_msg);
pb->rcs_msg = NULL;
}
return (0);
@@ -615,11 +603,11 @@ checkin_init(struct checkin_params *pb)
cvs_log(LP_ERR,
"failed to load description file '%s'",
pb->description);
- free(filec);
+ xfree(filec);
return (-1);
}
if (cvs_buf_putc(dp, '\0') < 0) {
- free(filec);
+ xfree(filec);
return (-1);
}
rcs_desc = (const char *)cvs_buf_release(dp);
@@ -655,7 +643,7 @@ checkin_init(struct checkin_params *pb)
if (pb->state != NULL)
(void)rcs_state_set(pb->file, pb->newrev, pb->state);
- free(filec);
+ xfree(filec);
(void)unlink(pb->filename);
/* Do checkout if -u or -l are specified. */
@@ -789,10 +777,7 @@ checkin_choose_rcsfile(const char *filename)
size_t len;
struct stat sb;
- if ((basepath = malloc(MAXPATHLEN)) == NULL) {
- cvs_log(LP_ERRNO, "could not allocate memory");
- return (NULL);
- }
+ basepath = xmalloc(MAXPATHLEN);
if (strchr(filename, '/') == NULL) {
strlcat(basepath, RCSDIR"/", MAXPATHLEN);
if ((stat(basepath, &sb) == 0) && (sb.st_mode & S_IFDIR)) {
@@ -820,7 +805,7 @@ checkin_choose_rcsfile(const char *filename)
*/
len += 2;
if (len > MAXPATHLEN) {
- free(basepath);
+ xfree(basepath);
return (NULL);
}
strlcpy(basepath, filename, len);
diff --git a/usr.bin/rcs/co.c b/usr.bin/rcs/co.c
index ed3ea8b4465..76b7373b312 100644
--- a/usr.bin/rcs/co.c
+++ b/usr.bin/rcs/co.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: co.c,v 1.46 2005/12/09 06:59:27 joris Exp $ */
+/* $OpenBSD: co.c,v 1.47 2005/12/10 20:27:46 joris Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -94,10 +94,7 @@ checkout_main(int argc, char **argv)
rcs_set_rev(rcs_optarg, &rev);
break;
case 's':
- if ((state = strdup(rcs_optarg)) == NULL) {
- cvs_log(LP_ERRNO, "out of memory");
- exit(1);
- }
+ state = xstrdup(rcs_optarg);
flags |= CO_STATE;
break;
case 'T':
@@ -118,11 +115,8 @@ checkout_main(int argc, char **argv)
"could not get login");
exit(1);
}
- } else if ((author = strdup(rcs_optarg)) == NULL) {
- cvs_log(LP_ERRNO, "out of memory");
- exit(1);
- }
-
+ } else
+ author = xstrdup(rcs_optarg);
flags |= CO_AUTHOR;
break;
case 'x':
@@ -350,7 +344,7 @@ checkout_rev(RCSFILE *file, RCSNUM *frev, const char *dst, int flags,
cvs_buf_putc(bp, '\0');
content = cvs_buf_release(bp);
printf("%s", content);
- free(content);
+ xfree(content);
} else {
if (cvs_buf_write(bp, dst, mode) < 0) {
cvs_log(LP_ERR, "failed to write revision to file");
diff --git a/usr.bin/rcs/rcsclean.c b/usr.bin/rcs/rcsclean.c
index 661431925a2..2eb67d7d5e5 100644
--- a/usr.bin/rcs/rcsclean.c
+++ b/usr.bin/rcs/rcsclean.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsclean.c,v 1.19 2005/12/08 18:56:10 joris Exp $ */
+/* $OpenBSD: rcsclean.c,v 1.20 2005/12/10 20:27:46 joris Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -190,8 +190,8 @@ rcsclean_file(char *fname, RCSNUM *rev)
}
}
- free(c1);
- free(c2);
+ xfree(c1);
+ xfree(c2);
if (match == 1) {
if ((uflag == 1) && (!TAILQ_EMPTY(&(file->rf_locks)))) {
diff --git a/usr.bin/rcs/rcsmerge.c b/usr.bin/rcs/rcsmerge.c
index 54d1296a339..9d1e44d4f9c 100644
--- a/usr.bin/rcs/rcsmerge.c
+++ b/usr.bin/rcs/rcsmerge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsmerge.c,v 1.10 2005/11/28 14:43:59 xsa Exp $ */
+/* $OpenBSD: rcsmerge.c,v 1.11 2005/12/10 20:27:46 joris Exp $ */
/*
* Copyright (c) 2005 Xavier Santolaria <xsa@openbsd.org>
* All rights reserved.
@@ -136,7 +136,7 @@ rcsmerge_main(int argc, char **argv)
fcont = cvs_buf_release(bp);
printf("%s", fcont);
- free(fcont);
+ xfree(fcont);
} else {
/* XXX mode */
if (cvs_buf_write(bp, argv[i], 0644) < 0)
diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c
index 6eb8eafbf56..37a02f36759 100644
--- a/usr.bin/rcs/rcsprog.c
+++ b/usr.bin/rcs/rcsprog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.c,v 1.52 2005/12/09 07:00:43 joris Exp $ */
+/* $OpenBSD: rcsprog.c,v 1.53 2005/12/10 20:27:46 joris Exp $ */
/*
* Copyright (c) 2005 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -153,19 +153,13 @@ rcs_init(char *envstr, char **argv, int argvlen)
break;
}
- argv[argc] = strdup(cp);
- if (argv[argc] == NULL) {
- cvs_log(LP_ERRNO, "failed to copy argument");
- error++;
- break;
- }
-
+ argv[argc] = xstrdup(cp);
argc++;
}
if (error != 0) {
for (i = 0; i < (u_int)argc; i++)
- free(argv[i]);
+ xfree(argv[i]);
argc = -1;
}
@@ -421,10 +415,7 @@ rcs_main(int argc, char **argv)
lkmode = RCS_LOCK_STRICT;
break;
case 'm':
- if ((logstr = strdup(rcs_optarg)) == NULL) {
- cvs_log(LP_ERRNO, "failed to copy logstring");
- exit(1);
- }
+ logstr = xstrdup(rcs_optarg);
break;
case 'M':
/* ignore for the moment */
@@ -551,7 +542,7 @@ rcs_main(int argc, char **argv)
}
if (logstr != NULL)
- free(logstr);
+ xfree(logstr);
return (0);
}
diff --git a/usr.bin/rcs/rcsprog.h b/usr.bin/rcs/rcsprog.h
index 24e8d3f1e6f..9bc4196a759 100644
--- a/usr.bin/rcs/rcsprog.h
+++ b/usr.bin/rcs/rcsprog.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsprog.h,v 1.30 2005/12/08 18:56:10 joris Exp $ */
+/* $OpenBSD: rcsprog.h,v 1.31 2005/12/10 20:27:46 joris Exp $ */
/*
* Copyright (c) 2005 Joris Vink <joris@openbsd.org>
* All rights reserved.
@@ -27,6 +27,8 @@
#ifndef RCSPROG_H
#define RCSPROG_H
+#include "xmalloc.h"
+
#define RCS_TMPDIR_DEFAULT "/tmp"
/* flags specific to ci.c */