]> mj.ucw.cz Git - libucw.git/commitdiff
Fastbuf: fbmulti: *'s and whitespace
authorJan 'Moskyt' Matejka <mq@ucw.cz>
Wed, 11 Jul 2012 14:46:44 +0000 (16:46 +0200)
committerJan 'Moskyt' Matejka <mq@ucw.cz>
Thu, 19 Jul 2012 13:25:28 +0000 (15:25 +0200)
ucw/fastbuf.h
ucw/fb-multi.c

index 564593dd16094e9ef32a4506b254042ea955f014..5c3ad1291c707ce88ee94f0c46c84b7ec8cc04a9 100644 (file)
@@ -488,8 +488,8 @@ static inline void fbatomic_commit(struct fastbuf *b)
  *
  * This backend is seekable iff all of the supplied fastbufs are seekable.
  *
- * Also, please be aware of direct operations on the underlying buffers. The
- * fbmulti backend doesn't expect you doing something directly on them.
+ * You aren't allowed to do anything with the underlying buffers while these
+ * are connected into fbmulti.
  *
  * You may init a fbmulti by @fbmulti_create(bufsize, fb1, fb2, ..., NULL).
  * This call returns a fastbuf that concatenates all the given fastbufs.
@@ -511,10 +511,11 @@ static inline void fbatomic_commit(struct fastbuf *b)
  * For performance reasons, use @fbmulti_flatten() only once, just before reading.
  ***/
 
-struct fastbuffbmulti_create(uns bufsize, ...) SENTINEL_CHECK;
+struct fastbuf *fbmulti_create(uns bufsize, ...) SENTINEL_CHECK;
 void fbmulti_append(struct fastbuf *f, struct fastbuf *fa, int allow_close);
 void fbmulti_flatten(struct fastbuf *f);
 
+
 /*** === Configuring stream parameters [[bconfig]] ***/
 
 enum bconfig_type {                    /** Parameters that could be configured. **/
index 876aac8b0e5948c711f0332a589f18fbc961ef6b..0bf6d9e4a0cdacf92ee3874a07313b07e1341634 100644 (file)
 
 struct fb_multi {
   struct fastbuf fb;
-  struct mempoolmp;
-  struct subbufcur;
+  struct mempool *mp;
+  struct subbuf *cur;
   ucw_off_t len;
-  clistsubbufs;
+  clist *subbufs;
 };
 
 #define FB_MULTI(f) ((struct fb_multi *)(f))
@@ -30,7 +30,7 @@ struct subbuf {
   cnode n;
   ucw_off_t begin, end;
   int allow_close;
-  struct fastbuffb;
+  struct fastbuf *fb;
 };
 
 static void
@@ -46,7 +46,7 @@ fbmulti_subbuf_get_end(struct subbuf *s)
 static int
 fbmulti_subbuf_next(struct fastbuf *f)
 {
-  struct subbufnext = clist_next(FB_MULTI(f)->subbufs, &FB_MULTI(f)->cur->n);
+  struct subbuf *next = clist_next(FB_MULTI(f)->subbufs, &FB_MULTI(f)->cur->n);
   if (next == NULL)
     return 0;
   
@@ -171,7 +171,7 @@ fbmulti_close(struct fastbuf *f)
   mp_delete(FB_MULTI(f)->mp);
 }
 
-struct fastbuf*
+struct fastbuf *
 fbmulti_create(uns bufsize, ...)
 {
   struct mempool *mp = mp_new(bufsize);
@@ -179,7 +179,7 @@ fbmulti_create(uns bufsize, ...)
   FB_MULTI(fb_out)->mp = mp;
 
   struct fastbuf *fb_in;
-  clistsubbufs = mp_alloc(mp, sizeof(clist));
+  clist *subbufs = mp_alloc(mp, sizeof(clist));
   clist_init(subbufs);
   FB_MULTI(fb_out)->subbufs = subbufs;
 
@@ -212,7 +212,7 @@ fbmulti_append(struct fastbuf *f, struct fastbuf *fb, int allow_close)
   clist_add_tail(FB_MULTI(f)->subbufs, &(sb->n));
 }
 
-static void fbmulti_flatten_internal(struct fastbuf *f, clistc, int allow_close)
+static void fbmulti_flatten_internal(struct fastbuf *f, clist *c, int allow_close)
 {
   CLIST_FOR_EACH(struct subbuf *, n, *c)
     {
@@ -241,7 +241,7 @@ fbmulti_flatten(struct fastbuf *f)
       return;
     }
   
-  clistc = FB_MULTI(f)->subbufs;
+  clist *c = FB_MULTI(f)->subbufs;
   FB_MULTI(f)->subbufs = mp_alloc(FB_MULTI(f)->mp, sizeof(clist));
   clist_init(FB_MULTI(f)->subbufs);
 
@@ -253,7 +253,7 @@ fbmulti_flatten(struct fastbuf *f)
 
 #ifdef TEST
 
-int main(int argc, char ** argv)
+int main(int argc, char **argv)
 {
   if (argc < 2)
     {
@@ -269,7 +269,7 @@ int main(int argc, char ** argv)
          for (uns i=0;i<ARRAY_SIZE(data);i++)
            fbbuf_init_read(&fb[i], data[i], strlen(data[i]), 0);
 
-         struct fastbuff = fbmulti_create(4, &fb[0], &fb[1], &fb[2], NULL);
+         struct fastbuf *f = fbmulti_create(4, &fb[0], &fb[1], &fb[2], NULL);
 
          char buffer[9];
          while (bgets(f, buffer, 9))
@@ -285,7 +285,7 @@ int main(int argc, char ** argv)
          for (uns i=0;i<ARRAY_SIZE(data);i++)
            fbbuf_init_read(&fb[i], data[i], strlen(data[i]), 0);
 
-         struct fastbuff = fbmulti_create(4, &fb[0], &fb[1], NULL);
+         struct fastbuf *f = fbmulti_create(4, &fb[0], &fb[1], NULL);
 
          int pos[] = {0, 3, 1, 4, 2, 5};
 
@@ -307,7 +307,7 @@ int main(int argc, char ** argv)
          fbbuf_init_read(&fb[2], data + 2, 2, 0);
          fbbuf_init_read(&fb[3], data + 4, 1, 0);
 
-         struct fastbuff = fbmulti_create(8, &fb[0], &fb[1], &fb[2], &fb[1], &fb[3], NULL);
+         struct fastbuf *f = fbmulti_create(8, &fb[0], &fb[1], &fb[2], &fb[1], &fb[3], NULL);
 
          char buffer[9];
          while(bgets(f, buffer, 9))