common: added functions for querying fragbuf state.
authorKrisztian Litkey <krisztian.litkey@intel.com>
Fri, 25 Jan 2013 14:21:51 +0000 (16:21 +0200)
committerKrisztian Litkey <kli@iki.fi>
Tue, 29 Jan 2013 15:51:49 +0000 (17:51 +0200)
src/common/fragbuf.c
src/common/fragbuf.h

index d95d190..8de6edc 100644 (file)
@@ -30,14 +30,20 @@ static void *fragbuf_ensure(mrp_fragbuf_t *buf, size_t size)
 }
 
 
-static size_t fragbuf_missing(mrp_fragbuf_t *buf)
+size_t mrp_fragbuf_used(mrp_fragbuf_t *buf)
+{
+    return buf->used;
+}
+
+
+size_t mrp_fragbuf_missing(mrp_fragbuf_t *buf)
 {
     void     *ptr;
     int       offs;
     uint32_t  size;
 
     if (!buf->framed || !buf->used)
-        return -1;
+        return 0;
 
     /* find the last frame */
     ptr  = buf->data;
index 2fcf06b..80403cb 100644 (file)
@@ -43,6 +43,12 @@ void mrp_fragbuf_reset(mrp_fragbuf_t *buf);
 /** Destroy the given data collector buffer, freeing all associated memory. */
 void mrp_fragbuf_destroy(mrp_fragbuf_t *buf);
 
+/** Return the amount of buffer space currently in used in th buffer. */
+size_t mrp_fragbuf_used(mrp_fragbuf_t *buf);
+
+/** Return the amount of bytes missing from the last message. */
+size_t mrp_fragbuf_missing(mrp_fragbuf_t *buf);
+
 /** Allocate a buffer of the given size from the buffer. */
 void *mrp_fragbuf_alloc(mrp_fragbuf_t *buf, size_t size);