]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fb-mem.c
Fixed bug in joining.
[libucw.git] / lib / fb-mem.c
index efe749c51ede07d18c1b1db6d4b2290ccd243e95..c304e16db0b988b73aaf630ecb0af0fe335fdebf 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- *     Sherlock Library -- Fast Buffered I/O on Memory Streams
+ *     UCW Library -- Fast Buffered I/O on Memory Streams
  *
  *     (c) 1997--2002 Martin Mares <mj@ucw.cz>
  *
  *
  *     (c) 1997--2002 Martin Mares <mj@ucw.cz>
  *
@@ -10,7 +10,7 @@
 #include "lib/lib.h"
 #include "lib/fastbuf.h"
 
 #include "lib/lib.h"
 #include "lib/fastbuf.h"
 
-#include <stdlib.h>
+#include <stdio.h>
 
 struct memstream {
   unsigned blocksize;
 
 struct memstream {
   unsigned blocksize;
@@ -95,7 +95,7 @@ fbmem_spout(struct fastbuf *f)
   FB_MEM(f)->block = bb;
 }
 
   FB_MEM(f)->block = bb;
 }
 
-static void
+static int
 fbmem_seek(struct fastbuf *f, sh_off_t pos, int whence)
 {
   struct memstream *m = FB_MEM(f)->stream;
 fbmem_seek(struct fastbuf *f, sh_off_t pos, int whence)
 {
   struct memstream *m = FB_MEM(f)->stream;
@@ -117,7 +117,7 @@ fbmem_seek(struct fastbuf *f, sh_off_t pos, int whence)
          f->bufend = f->bstop = b->data + b->size;
          f->pos = b->pos + b->size;
          FB_MEM(f)->block = b;
          f->bufend = f->bstop = b->data + b->size;
          f->pos = b->pos + b->size;
          FB_MEM(f)->block = b;
-         return;
+         return 1;
        }
     }
   if (!m->first && !pos)
        }
     }
   if (!m->first && !pos)
@@ -126,7 +126,7 @@ fbmem_seek(struct fastbuf *f, sh_off_t pos, int whence)
       f->buffer = f->bptr = f->bufend = NULL;
       f->pos = 0;
       FB_MEM(f)->block = NULL;
       f->buffer = f->bptr = f->bufend = NULL;
       f->pos = 0;
       FB_MEM(f)->block = NULL;
-      return;
+      return 1;
     }
   die("fbmem_seek to invalid offset");
 }
     }
   die("fbmem_seek to invalid offset");
 }
@@ -149,18 +149,6 @@ fbmem_close(struct fastbuf *f)
   xfree(f);
 }
 
   xfree(f);
 }
 
-static int
-fbmem_config(struct fastbuf *f UNUSED, uns item, int value UNUSED)
-{
-  switch (item)
-    {
-    case BCONFIG_CAN_OVERWRITE:
-      return 1;
-    default:
-      return -1;
-    }
-}
-
 struct fastbuf *
 fbmem_create(unsigned blocksize)
 {
 struct fastbuf *
 fbmem_create(unsigned blocksize)
 {
@@ -174,7 +162,6 @@ fbmem_create(unsigned blocksize)
   f->name = "<fbmem-write>";
   f->spout = fbmem_spout;
   f->close = fbmem_close;
   f->name = "<fbmem-write>";
   f->spout = fbmem_spout;
   f->close = fbmem_close;
-  f->config = fbmem_config;
   return f;
 }
 
   return f;
 }
 
@@ -192,7 +179,7 @@ fbmem_clone_read(struct fastbuf *b)
   f->refill = fbmem_refill;
   f->seek = fbmem_seek;
   f->close = fbmem_close;
   f->refill = fbmem_refill;
   f->seek = fbmem_seek;
   f->close = fbmem_close;
-  f->config = fbmem_config;
+  f->can_overwrite_buffer = 1;
   return f;
 }
 
   return f;
 }