summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/import.c22
-rw-r--r--usr.bin/cvs/init.c14
2 files changed, 12 insertions, 24 deletions
diff --git a/usr.bin/cvs/import.c b/usr.bin/cvs/import.c
index bdb551d48bf..3b5456a056c 100644
--- a/usr.bin/cvs/import.c
+++ b/usr.bin/cvs/import.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: import.c,v 1.61 2007/01/12 23:32:01 niallo Exp $ */
+/* $OpenBSD: import.c,v 1.62 2007/01/13 20:29:46 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -27,7 +27,7 @@ void cvs_import_local(struct cvs_file *);
static void import_new(struct cvs_file *);
static void import_update(struct cvs_file *);
static void import_tag(struct cvs_file *, RCSNUM *, RCSNUM *);
-static char *import_get_rcsdiff(struct cvs_file *, RCSNUM *);
+static BUF *import_get_rcsdiff(struct cvs_file *, RCSNUM *);
#define IMPORT_DEFAULT_BRANCH "1.1.1"
@@ -247,8 +247,8 @@ import_new(struct cvs_file *cf)
static void
import_update(struct cvs_file *cf)
{
- BUF *b1, *b2;
- char *d, branch[16];
+ BUF *b1, *b2, *d;
+ char branch[16];
RCSNUM *newrev, *rev, *brev;
cvs_log(LP_TRACE, "import_update(%s)", cf->file_path);
@@ -294,8 +294,7 @@ import_update(struct cvs_file *cf)
if (rcs_deltatext_set(cf->file_rcs, newrev, d) == -1)
fatal("import_update: failed to set deltatext");
- xfree(d);
-
+ cvs_buf_free(d);
import_tag(cf, brev, newrev);
if (cf->file_rcs->rf_branch == NULL || cf->file_rcs->rf_inattic == 1 ||
@@ -327,10 +326,10 @@ import_tag(struct cvs_file *cf, RCSNUM *branch, RCSNUM *newrev)
}
}
-static char *
+static BUF *
import_get_rcsdiff(struct cvs_file *cf, RCSNUM *rev)
{
- char *delta, *p1, *p2;
+ char *p1, *p2;
BUF *b1, *b2;
if ((b1 = cvs_buf_load_fd(cf->fd, BUF_AUTOEXT)) == NULL)
@@ -359,13 +358,8 @@ import_get_rcsdiff(struct cvs_file *cf, RCSNUM *rev)
xfree(p2);
}
- cvs_buf_putc(b2, '\0');
- delta = cvs_buf_release(b2);
-
if (b1 != NULL)
cvs_buf_free(b1);
- if (b2 != NULL)
- cvs_buf_free(b2);
- return (delta);
+ return (b2);
}
diff --git a/usr.bin/cvs/init.c b/usr.bin/cvs/init.c
index a42f4e46947..4cc4b20ecb8 100644
--- a/usr.bin/cvs/init.c
+++ b/usr.bin/cvs/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.27 2007/01/11 02:35:55 joris Exp $ */
+/* $OpenBSD: init.c,v 1.28 2007/01/13 20:29:46 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* Copyright (c) 2006 Xavier Santolaria <xsa@openbsd.org>
@@ -144,13 +144,12 @@ init_mkfile(char *path, const char *const *content)
BUF *b;
size_t len;
int fd, openflags, rcsflags;
- char *d, *rpath;
+ char *rpath;
const char *const *p;
RCSFILE *file;
len = 0;
fd = -1;
- d = NULL;
openflags = O_WRONLY|O_CREAT|O_EXCL;
rcsflags = RCS_RDWR|RCS_CREATE;
@@ -192,13 +191,11 @@ init_mkfile(char *path, const char *const *content)
if ((b = cvs_buf_load(path, BUF_AUTOEXT)) == NULL)
fatal("init_mkfile: failed to load %s", path);
- cvs_buf_putc(b, '\0');
- d = cvs_buf_release(b);
-
if (rcs_rev_add(file, RCS_HEAD_REV, "initial checkin", -1, NULL) == -1)
fatal("init_mkfile: failed to add new revision");
- if (rcs_deltatext_set(file, file->rf_head, d) == -1)
+ /* b buffer is free'd in rcs_deltatext_set */
+ if (rcs_deltatext_set(file, file->rf_head, b) == -1)
fatal("init_mkfile: failed to set delta");
file->rf_flags &= ~RCS_SYNCED;
@@ -206,7 +203,4 @@ init_mkfile(char *path, const char *const *content)
xfree(rpath);
out:
(void)close(fd);
-
- if (d != NULL)
- xfree(d);
}