summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/buffer.c b/buffer.c
index 6ad9bb2e9..b4c166d0e 100644
--- a/buffer.c
+++ b/buffer.c
@@ -14,7 +14,7 @@
14 */ 14 */
15 15
16#include "includes.h" 16#include "includes.h"
17RCSID("$Id: buffer.c,v 1.2 1999/11/24 13:26:22 damien Exp $"); 17RCSID("$Id: buffer.c,v 1.3 1999/11/25 00:54:58 damien Exp $");
18 18
19#include "xmalloc.h" 19#include "xmalloc.h"
20#include "buffer.h" 20#include "buffer.h"
@@ -40,8 +40,10 @@ buffer_free(Buffer *buffer)
40 xfree(buffer->buf); 40 xfree(buffer->buf);
41} 41}
42 42
43/* Clears any data from the buffer, making it empty. This does not actually 43/*
44 zero the memory. */ 44 * Clears any data from the buffer, making it empty. This does not actually
45 * zero the memory.
46 */
45 47
46void 48void
47buffer_clear(Buffer *buffer) 49buffer_clear(Buffer *buffer)
@@ -60,9 +62,11 @@ buffer_append(Buffer *buffer, const char *data, unsigned int len)
60 memcpy(cp, data, len); 62 memcpy(cp, data, len);
61} 63}
62 64
63/* Appends space to the buffer, expanding the buffer if necessary. 65/*
64 This does not actually copy the data into the buffer, but instead 66 * Appends space to the buffer, expanding the buffer if necessary. This does
65 returns a pointer to the allocated region. */ 67 * not actually copy the data into the buffer, but instead returns a pointer
68 * to the allocated region.
69 */
66 70
67void 71void
68buffer_append_space(Buffer *buffer, char **datap, unsigned int len) 72buffer_append_space(Buffer *buffer, char **datap, unsigned int len)
@@ -79,8 +83,10 @@ restart:
79 buffer->end += len; 83 buffer->end += len;
80 return; 84 return;
81 } 85 }
82 /* If the buffer is quite empty, but all data is at the end, move 86 /*
83 the data to the beginning and retry. */ 87 * If the buffer is quite empty, but all data is at the end, move the
88 * data to the beginning and retry.
89 */
84 if (buffer->offset > buffer->alloc / 2) { 90 if (buffer->offset > buffer->alloc / 2) {
85 memmove(buffer->buf, buffer->buf + buffer->offset, 91 memmove(buffer->buf, buffer->buf + buffer->offset,
86 buffer->end - buffer->offset); 92 buffer->end - buffer->offset);