Changeset: b2e3e3282355 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b2e3e3282355
Modified Files:
        common/stream/stream.c
        common/stream/stream.h
Branch: default
Log Message:

Cleanup stream: remove some functions that are not used anywhere.
Removed: dupFileStream, bs_read_next, detach_teestream, attach_teestream.


diffs (184 lines):

diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -642,19 +642,6 @@ open_stream(const char *filename, const 
        return s;
 }
 
-stream *
-dupFileStream(stream *s)
-{
-       stream *ns;
-       if (s->read != file_read)
-               return NULL;
-       if (s->access == ST_WRITE)
-               ns = open_stream(s->name, "w");
-       else
-               ns = open_stream(s->name, "r");
-       return ns;
-}
-
 /* ------------------------------------------------------------------ */
 /* streams working on a gzip-compressed disk file */
 
@@ -2679,30 +2666,6 @@ bs_update_timeout(stream *ss)
        }
 }
 
-/* Read the next bit of a block.  If this was the last bit of the
- * current block, set the value pointed to by last to 1, otherwise set
- * it to 0. */
-ssize_t
-bs_read_next(stream *ss, void *buf, size_t nbytes, int *last)
-{
-       ssize_t n;
-       bs *s = (bs *) ss->stream_data.p;
-
-       n = bs_read(ss, buf, 1, nbytes);
-       if (n < 0) {
-               if (last)
-                       *last = 1;
-               return -1;
-       }
-       if (last)
-               *last = s->itotal == 0;
-       if (s->itotal == 0) {
-               /* we don't want to get an empty buffer at the next read */
-               s->nr = 0;
-       }
-       return n;
-}
-
 static void
 bs_close(stream *ss)
 {
@@ -2764,99 +2727,6 @@ isa_block_stream(stream *s)
 
 /* ------------------------------------------------------------------ */
 
-/* A tee stream just duplicates the output of a stream to to streams */
-
-typedef struct {
-       stream *orig, *log;
-} tee_stream;
-
-static ssize_t
-ts_write(stream *s, const void *buf, size_t elmsize, size_t cnt)
-{
-       tee_stream *ts = (tee_stream *) s->stream_data.p;
-       ssize_t reorig = ts->orig->write(ts->orig, buf, elmsize, cnt);
-       ssize_t relog = ts->log->write(ts->log, buf, elmsize, cnt);
-       return reorig < relog ? reorig : relog;
-}
-
-static int
-ts_flush(stream *s)
-{
-       tee_stream *ts = (tee_stream *) s->stream_data.p;
-       int reorig = ts->orig->flush(ts->orig);
-       int relog = ts->log->flush(ts->log);
-       return reorig < relog ? reorig : relog;
-}
-
-static void
-ts_close(stream *s)
-{
-       tee_stream *ts = (tee_stream *) s->stream_data.p;
-       ts->orig->close(ts->orig);
-       ts->log->close(ts->log);
-}
-
-static void
-ts_destroy(stream *s)
-{
-       tee_stream *ts = (tee_stream *) s->stream_data.p;
-       ts->orig->destroy(ts->orig);
-       ts->log->destroy(ts->log);
-       free(ts);
-       destroy(s);
-}
-
-void
-detach_teestream(stream *s)
-{
-       tee_stream *ts = (tee_stream *) s->stream_data.p;
-       ts->log->close(ts->log);
-       ts->log->destroy(ts->log);
-       free(ts);
-       destroy(s);
-}
-
-stream *
-attach_teestream(stream *orig, stream *log)
-{
-       tee_stream *ts;
-       stream *ns;
-
-       /* we require two write streams of the same type */
-       if (orig == NULL || log == NULL || orig->access != ST_WRITE || 
log->access != ST_WRITE)
-               return NULL;
-       ts = (tee_stream *) malloc(sizeof(tee_stream));
-
-       if (ts == NULL)
-               return NULL;
-       ts->orig = orig;
-       ts->log = log;
-
-#ifdef STREAM_DEBUG
-       printf("tee_stream %s %s\n", orig->name ? orig->name : "<unnamed>", 
log->name ? log->name : "<unnamed>");
-#endif
-       if ((ns = create_stream(orig->name)) == NULL) {
-               free(ts);
-               return NULL;
-       }
-       /* blocksizes have a fixed little endian byteorder */
-#ifdef WORDS_BIGENDIAN
-       ns->byteorder = 3412;   /* simply != 1234 */
-#endif
-       ns->type = orig->type;
-       ns->access = orig->access;
-       ns->write = ts_write;
-       ns->close = ts_close;
-       ns->flush = ts_flush;
-       ns->destroy = ts_destroy;
-       ns->stream_data.p = (void *) ts;
-
-       return ns;
-}
-
-
-/* ------------------------------------------------------------------ */
-
 ssize_t
 mnstr_read_block(stream *s, void *buf, size_t elmsize, size_t cnt)
 {
diff --git a/common/stream/stream.h b/common/stream/stream.h
--- a/common/stream/stream.h
+++ b/common/stream/stream.h
@@ -173,7 +173,6 @@ stream_export stream *file_rastream(FILE
 stream_export stream *file_wastream(FILE *fp, const char *name);
 
 stream_export FILE *getFile(stream *s);
-stream_export stream *dupFileStream(stream *s);
 
 stream_export stream *iconv_rstream(stream *ss, const char *charset, const 
char *name);
 stream_export stream *iconv_wstream(stream *ss, const char *charset, const 
char *name);
@@ -215,7 +214,6 @@ stream_export buffer *mnstr_get_buffer(s
  */
 stream_export stream *wbstream(stream *s, size_t buflen);
 stream_export stream *block_stream(stream *s);
-stream_export ssize_t bs_read_next(stream *s, void *buf, size_t nbytes, int 
*last);
 stream_export int isa_block_stream(stream *s);
 /* read block of data including the end of block marker */
 stream_export ssize_t mnstr_read_block(stream *s, void *buf, size_t elmsize, 
size_t cnt);
@@ -235,10 +233,6 @@ stream_export void bstream_destroy(bstre
 stream_export ssize_t bstream_read(bstream *s, size_t size);
 stream_export ssize_t bstream_next(bstream *s);
 
-stream_export stream *attach_teestream(stream *orig, stream *log);
-stream_export void detach_teestream(stream *ts);
-
-
 typedef enum mnstr_errors {
        MNSTR_NO__ERROR = 0,
        MNSTR_OPEN_ERROR,
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to