Code

utils/strbuf: Added SDB_STRBUF_STR.
authorSebastian Harl <sh@tokkee.org>
Wed, 17 Dec 2014 21:53:55 +0000 (22:53 +0100)
committerSebastian Harl <sh@tokkee.org>
Wed, 17 Dec 2014 21:53:55 +0000 (22:53 +0100)
This macro returns a tuple describing the buffer content and length. The idea
is that functions which operate on (binary) strings should accept two such
arguments and the macro will make it easier to pass them in.

src/include/utils/strbuf.h

index c14192daa0a2dede951a39f7b77b413e46f3b2f5..a9e915537c9d97c03fd94310cfb58b66a3041c34 100644 (file)
@@ -45,6 +45,13 @@ extern "C" {
 
 typedef struct sdb_strbuf sdb_strbuf_t;
 
 
 typedef struct sdb_strbuf sdb_strbuf_t;
 
+/*
+ * SDB_STRBUF_STR:
+ * Return a tuple of a character array and its length representing the content
+ * of the string buffer.
+ */
+#define SDB_STRBUF_STR(buf) sdb_strbuf_string(buf), sdb_strbuf_len(buf)
+
 /*
  * sdb_strbuf_create, sdb_strbuf_destroy:
  * Allocate / deallocate string buffer objects. The initial size of a newly
 /*
  * sdb_strbuf_create, sdb_strbuf_destroy:
  * Allocate / deallocate string buffer objects. The initial size of a newly