summaryrefslogtreecommitdiffstats
path: root/usr.bin/cvs/buf.c
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2004-12-07 17:10:56 +0000
committertedu <tedu@openbsd.org>2004-12-07 17:10:56 +0000
commita176bc3ee0772f34303003a5d023d099e5458b4c (patch)
tree700dea46dcad9da741b27f39f1f6156607eff32f /usr.bin/cvs/buf.c
parentavoid a crash when receiving either a Created, Updated, Update-existing (diff)
downloadwireguard-openbsd-a176bc3ee0772f34303003a5d023d099e5458b4c.tar.xz
wireguard-openbsd-a176bc3ee0772f34303003a5d023d099e5458b4c.zip
less whitespace, more pretty. ok jfb
Diffstat (limited to 'usr.bin/cvs/buf.c')
-rw-r--r--usr.bin/cvs/buf.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/usr.bin/cvs/buf.c b/usr.bin/cvs/buf.c
index 7efbec219a4..d9ae11b87f4 100644
--- a/usr.bin/cvs/buf.c
+++ b/usr.bin/cvs/buf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.c,v 1.5 2004/12/06 21:03:12 deraadt Exp $ */
+/* $OpenBSD: buf.c,v 1.6 2004/12/07 17:10:56 tedu Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -70,7 +70,6 @@ static ssize_t cvs_buf_grow (BUF *, size_t);
* uses dynamically-allocated memory and must be freed with cvs_buf_free(),
* once the buffer is no longer needed.
*/
-
BUF*
cvs_buf_alloc(size_t len, u_int flags)
{
@@ -106,7 +105,6 @@ cvs_buf_alloc(size_t len, u_int flags)
* buffer.
* Returns the loaded buffer on success, or NULL on failure.
*/
-
BUF*
cvs_buf_load(const char *path, u_int flags)
{
@@ -160,7 +158,6 @@ cvs_buf_load(const char *path, u_int flags)
*
* Free the buffer <b> and all associated data.
*/
-
void
cvs_buf_free(BUF *b)
{
@@ -176,11 +173,11 @@ cvs_buf_free(BUF *b)
* of the buffer. Instead, they are returned and should be freed later using
* free().
*/
-
void*
cvs_buf_release(BUF *b)
{
void *tmp;
+
tmp = b->cb_buf;
free(b);
return (tmp);
@@ -192,7 +189,6 @@ cvs_buf_release(BUF *b)
*
* Empty the contents of the buffer <b> and reset pointers.
*/
-
void
cvs_buf_empty(BUF *b)
{
@@ -208,7 +204,6 @@ cvs_buf_empty(BUF *b)
* <off> in the destination buffer <dst>, which can accept up to <len> bytes.
* Returns the number of bytes successfully copied, or -1 on failure.
*/
-
ssize_t
cvs_buf_copy(BUF *b, size_t off, void *dst, size_t len)
{
@@ -231,14 +226,13 @@ cvs_buf_copy(BUF *b, size_t off, void *dst, size_t len)
* at <src>. If the buffer was not created with BUF_AUTOEXT, as many bytes
* as possible will be copied in the buffer.
*/
-
int
cvs_buf_set(BUF *b, const void *src, size_t len, size_t off)
{
size_t rlen;
if (b->cb_size < (len + off)) {
- if ((b->cb_flags & BUF_AUTOEXT) && (cvs_buf_grow(b,
+ if ((b->cb_flags & BUF_AUTOEXT) && (cvs_buf_grow(b,
len + off - b->cb_size) < 0))
return (-1);
else
@@ -263,7 +257,6 @@ cvs_buf_set(BUF *b, const void *src, size_t len, size_t off)
* Append a single character <c> to the end of the buffer <b>.
* Returns 0 on success, or -1 on failure.
*/
-
int
cvs_buf_putc(BUF *b, int c)
{
@@ -296,7 +289,6 @@ cvs_buf_putc(BUF *b, int c)
* Returns the number of bytes successfully appended to the buffer, or -1
* on failure.
*/
-
ssize_t
cvs_buf_append(BUF *b, const void *data, size_t len)
{
@@ -328,7 +320,6 @@ cvs_buf_append(BUF *b, const void *data, size_t len)
* cvs_buf_fappend()
*
*/
-
int
cvs_buf_fappend(BUF *b, const char *fmt, ...)
{
@@ -356,7 +347,6 @@ cvs_buf_fappend(BUF *b, const char *fmt, ...)
*
* Returns the size of the buffer that is being used.
*/
-
size_t
cvs_buf_size(BUF *b)
{
@@ -369,7 +359,6 @@ cvs_buf_size(BUF *b)
*
* Peek at the contents of the buffer <b> at offset <off>.
*/
-
const void*
cvs_buf_peek(BUF *b, size_t off)
{
@@ -386,7 +375,6 @@ cvs_buf_peek(BUF *b, size_t off)
* Write the contents of the buffer <b> to the file whose path is given in
* <path>. If the file does not exist, it is created with mode <mode>.
*/
-
int
cvs_buf_write(BUF *b, const char *path, mode_t mode)
{
@@ -430,7 +418,6 @@ cvs_buf_write(BUF *b, const char *path, mode_t mode)
* operation regardless of the result.
* Returns the new size on success, or -1 on failure.
*/
-
static ssize_t
cvs_buf_grow(BUF *b, size_t len)
{