aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/ChangeLog5
-rw-r--r--common/iobuf.c46
-rw-r--r--common/iobuf.h17
3 files changed, 11 insertions, 57 deletions
diff --git a/common/ChangeLog b/common/ChangeLog
index 4e385e109..7fc6af2e5 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,8 @@
+2006-10-02 Werner Koch <[email protected]>
+
+ * iobuf.c (iobuf_unread): Removed. This code is not required.
+ Also removed the entire unget buffer stuff.
+
2006-09-27 Werner Koch <[email protected]>
* util.h: Do not include strsep.h and strpbrk.h.
diff --git a/common/iobuf.c b/common/iobuf.c
index 9b13f8b02..113d35bb4 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -1037,7 +1037,6 @@ iobuf_close (iobuf_t a)
{
memset (a->d.buf, 0, a->d.size); /* erase the buffer */
xfree (a->d.buf);
- xfree (a->unget.buf);
}
xfree (a);
}
@@ -1539,7 +1538,6 @@ pop_filter (iobuf_t a, int (*f) (void *opaque, int control,
b = a->chain;
assert (b);
xfree (a->d.buf);
- xfree (a->unget.buf);
xfree (a->real_fname);
memcpy (a, b, sizeof *a);
xfree (b);
@@ -1581,7 +1579,6 @@ pop_filter (iobuf_t a, int (*f) (void *opaque, int control,
*/
b = a->chain;
xfree (a->d.buf);
- xfree (a->unget.buf);
xfree (a->real_fname);
memcpy (a, b, sizeof *a);
xfree (b);
@@ -1624,7 +1621,6 @@ underflow (iobuf_t a)
log_debug ("iobuf-%d.%d: pop `%s' in underflow\n",
a->no, a->subno, a->desc);
xfree (a->d.buf);
- xfree (a->unget.buf);
xfree (a->real_fname);
memcpy (a, b, sizeof *a);
xfree (b);
@@ -1699,7 +1695,6 @@ underflow (iobuf_t a)
log_debug ("iobuf-%d.%d: pop `%s' in underflow (!len)\n",
a->no, a->subno, a->desc);
xfree (a->d.buf);
- xfree (a->unget.buf);
xfree (a->real_fname);
memcpy (a, b, sizeof *a);
xfree (b);
@@ -1780,17 +1775,6 @@ iobuf_readbyte (iobuf_t a)
{
int c;
- /* nlimit does not work together with unget */
- /* nbytes is also not valid! */
- if (a->unget.buf)
- {
- if (a->unget.start < a->unget.len)
- return a->unget.buf[a->unget.start++];
- xfree (a->unget.buf);
- a->unget.buf = NULL;
- a->nofast &= ~2;
- }
-
if (a->nlimit && a->nbytes >= a->nlimit)
return -1; /* forced EOF */
@@ -1812,9 +1796,9 @@ iobuf_read (iobuf_t a, void *buffer, unsigned int buflen)
unsigned char *buf = (unsigned char *)buffer;
int c, n;
- if (a->unget.buf || a->nlimit)
+ if (a->nlimit)
{
- /* handle special cases */
+ /* Handle special cases. */
for (n = 0; n < buflen; n++)
{
if ((c = iobuf_readbyte (a)) == -1)
@@ -1865,30 +1849,6 @@ iobuf_read (iobuf_t a, void *buffer, unsigned int buflen)
-/* This is a verly limited unget fucntion for an iobuf. It does only
- work in certain cases and should be used with care. */
-void
-iobuf_unread (iobuf_t a, const unsigned char *buf, unsigned int buflen)
-{
- unsigned int new_len;
-
- if (!buflen)
- return;
-
- /* We always relocate the buffer, which is not optimal. However,
- the code is easier to read this way, and it is not on the fast
- path. */
- if ( !a->unget.buf )
- a->unget.size = a->unget.start = a->unget.len = 0;
-
- new_len = a->unget.len + buflen;
- a->unget.buf = xrealloc(a->unget.buf, new_len);
- memcpy(a->unget.buf + a->unget.len, buf, buflen);
- a->unget.len = new_len;
- a->nofast |= 2;
-}
-
-
/****************
* Have a look at the iobuf.
* NOTE: This only works in special cases.
@@ -1905,7 +1865,7 @@ iobuf_peek (iobuf_t a, byte * buf, unsigned buflen)
{
if (underflow (a) == -1)
return -1;
- /* and unget this character */
+ /* And unget this character. */
assert (a->d.start == 1);
a->d.start = 0;
}
diff --git a/common/iobuf.h b/common/iobuf.h
index 55c0b3b6d..fa11f3905 100644
--- a/common/iobuf.h
+++ b/common/iobuf.h
@@ -47,8 +47,6 @@ struct iobuf_struct
off_t nbytes; /* Used together with nlimit. */
off_t ntotal; /* Total bytes read (position of stream). */
int nofast; /* Used by the iobuf_get (). */
- /* bit 0 (LSB): slow path because of limit. */
- /* bit 1: slow path because of unread. */
void *directfp;
struct
{
@@ -63,24 +61,16 @@ struct iobuf_struct
int error;
int (*filter) (void *opaque, int control,
iobuf_t chain, byte * buf, size_t * len);
- void *filter_ov; /* value for opaque */
+ void *filter_ov; /* Value for opaque */
int filter_ov_owner;
char *real_fname;
- iobuf_t chain; /* next iobuf used for i/o if any
+ iobuf_t chain; /* Next iobuf used for i/o if any
(passed to filter) */
int no, subno;
const char *desc;
- void *opaque; /* can be used to hold any information
+ void *opaque; /* Can be used to hold any information
this value is copied to all
instances */
- struct
- {
- size_t size; /* allocated size */
- size_t start; /* number of invalid bytes at the
- begin of the buffer */
- size_t len; /* currently filled to this size */
- byte *buf;
- } unget;
};
#ifndef EXTERN_UNLESS_MAIN_MODULE
@@ -137,7 +127,6 @@ int iobuf_writestr (iobuf_t a, const char *buf);
void iobuf_flush_temp (iobuf_t temp);
int iobuf_write_temp (iobuf_t a, iobuf_t temp);
size_t iobuf_temp_to_buffer (iobuf_t a, byte * buffer, size_t buflen);
-void iobuf_unget_and_close_temp (iobuf_t a, iobuf_t temp);
off_t iobuf_get_filelength (iobuf_t a, int *overflow);
#define IOBUF_FILELENGTH_LIMIT 0xffffffff