Add test for gbuf

This commit is contained in:
Nils O. Selåsdal
2012-11-18 13:45:52 +01:00
parent 9547730c9e
commit 65a6c67277
4 changed files with 59 additions and 4 deletions
+14 -3
View File
@@ -26,7 +26,7 @@ struct GBuf {
void *buf;
};
/** Allocatea new GBuf.
/** Allocate a new GBuf.
*
* @param initsz Intial capacity of the GBuf
* @return New GBuf, or NULL if allocation fails,
@@ -56,7 +56,18 @@ void uc_gbuf_unref(GBuf *buf);
* @return 0 on success, -1 on failure when allocation fails if he buffer
* needs to grow
*/
int uc_gbuf_append(GBuf *buf,void *data,size_t len);
int uc_gbuf_append(GBuf *buf,const void *data,size_t len);
/** Do printf formatting on a GBuf.
* The buffer will grow as needed.
*
* @param buf The GBuf
* @param fmt printf stype formatting string
* @param ... format arguments
*
* @return The number of chars written, or negative if an error occurs
*/
int uc_gbuf_printf(GBuf *buf, const char *fmt, ...);
/** Expand the capacity of the GBuf.
*
@@ -69,7 +80,7 @@ int uc_gbuf_grow(GBuf *buf, size_t addlen);
* @param buff buffer
* @return length of unused space
*/
size_t uc_gbuf_remaining(const GBuf *buf)
static inline size_t uc_gbuf_remaining(const GBuf *buf)
{
return buf->len - buf->used;
}