summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4fd156c)
raw | patch | inline | side by side (parent: 4fd156c)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 16 May 2014 06:49:38 +0000 (08:49 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 16 May 2014 06:49:38 +0000 (08:49 +0200) |
This function returns the "capacity" of the string buffer. It's useful mostly
for testing, debugging, etc.
for testing, debugging, etc.
src/include/utils/strbuf.h | patch | blob | history | |
src/utils/strbuf.c | patch | blob | history |
index 96b4f86bee3aa8937899a9af08314f9fa5866860..20cf8706b53038165e73d7892401eb8066e94b59 100644 (file)
size_t
sdb_strbuf_len(sdb_strbuf_t *strbuf);
+/*
+ * sdb_strbuf_cap:
+ * Returns the current capacity of the string buffer. It describes the max
+ * length of the buffer's content (including terminating nul byte) that may be
+ * stored in the buffer without resizing it.
+ */
+size_t
+sdb_strbuf_cap(sdb_strbuf_t *strbuf);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/src/utils/strbuf.c b/src/utils/strbuf.c
index 0474677296c31f9c1fcce3ded0a0207fde621c8a..7d8bc5527f6138f7a1c8ad6cf6730c6445c3460b 100644 (file)
--- a/src/utils/strbuf.c
+++ b/src/utils/strbuf.c
return strbuf->pos;
} /* sdb_strbuf_string */
+size_t
+sdb_strbuf_cap(sdb_strbuf_t *strbuf)
+{
+ if (! strbuf)
+ return 0;
+ return strbuf->size;
+} /* sdb_strbuf_cap */
+
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */