summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authordjm <djm>2001-12-21 03:56:54 +0000
committerdjm <djm>2001-12-21 03:56:54 +0000
commit0d21009d45b1594a113d283b5004c851db09c7a1 (patch)
treee4a60c08ef0c6abd40404519e91d2357da46588b /buffer.c
parentec400f57c4d35357801c382e4181ed34e45ab447 (diff)
downloadopenssh-0d21009d45b1594a113d283b5004c851db09c7a1.tar.gz
- stevesk@cvs.openbsd.org 2001/12/19 17:16:13
[authfile.c bufaux.c bufaux.h buffer.c buffer.h packet.c packet.h ssh.c] change the buffer/packet interface to use void* vs. char*; ok markus@
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/buffer.c b/buffer.c
index 044caafb..a1152d1d 100644
--- a/buffer.c
+++ b/buffer.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: buffer.c,v 1.13 2001/04/12 19:15:24 markus Exp $");
+RCSID("$OpenBSD: buffer.c,v 1.14 2001/12/19 17:16:13 stevesk Exp $");
#include "xmalloc.h"
#include "buffer.h"
@@ -53,11 +53,11 @@ buffer_clear(Buffer *buffer)
/* Appends data to the buffer, expanding it if necessary. */
void
-buffer_append(Buffer *buffer, const char *data, u_int len)
+buffer_append(Buffer *buffer, const void *data, u_int len)
{
- char *cp;
- buffer_append_space(buffer, &cp, len);
- memcpy(cp, data, len);
+ void *p;
+ p = buffer_append_space(buffer, len);
+ memcpy(p, data, len);
}
/*
@@ -66,9 +66,11 @@ buffer_append(Buffer *buffer, const char *data, u_int len)
* to the allocated region.
*/
-void
-buffer_append_space(Buffer *buffer, char **datap, u_int len)
+void *
+buffer_append_space(Buffer *buffer, u_int len)
{
+ void *p;
+
/* If the buffer is empty, start using it from the beginning. */
if (buffer->offset == buffer->end) {
buffer->offset = 0;
@@ -77,9 +79,9 @@ buffer_append_space(Buffer *buffer, char **datap, u_int len)
restart:
/* If there is enough space to store all data, store it now. */
if (buffer->end + len < buffer->alloc) {
- *datap = buffer->buf + buffer->end;
+ p = buffer->buf + buffer->end;
buffer->end += len;
- return;
+ return p;
}
/*
* If the buffer is quite empty, but all data is at the end, move the
@@ -96,6 +98,7 @@ restart:
buffer->alloc += len + 32768;
buffer->buf = xrealloc(buffer->buf, buffer->alloc);
goto restart;
+ /* NOTREACHED */
}
/* Returns the number of bytes of data in the buffer. */
@@ -109,7 +112,7 @@ buffer_len(Buffer *buffer)
/* Gets data from the beginning of the buffer. */
void
-buffer_get(Buffer *buffer, char *buf, u_int len)
+buffer_get(Buffer *buffer, void *buf, u_int len)
{
if (len > buffer->end - buffer->offset)
fatal("buffer_get: trying to get more bytes %d than in buffer %d",
@@ -140,7 +143,7 @@ buffer_consume_end(Buffer *buffer, u_int bytes)
/* Returns a pointer to the first used byte in the buffer. */
-char *
+void *
buffer_ptr(Buffer *buffer)
{
return buffer->buf + buffer->offset;