aboutsummaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-01-04 13:30:56 -0500
committerNick Mathewson <nickm@torproject.org>2014-02-12 12:47:49 -0500
commitf425cf833852c4e1b4660cbba6190d04b070f6b6 (patch)
treeb93bf3c9eede44bd6ff09b6d8f248623143d57cd /src/or/buffers.c
parenteb6f433bdbd6cf44e1f35272ed04a6c0e14f3c2d (diff)
downloadtor-f425cf833852c4e1b4660cbba6190d04b070f6b6.tar
tor-f425cf833852c4e1b4660cbba6190d04b070f6b6.tar.gz
Start writing tests for 10169.
Now we cover more chunk allocation functions.
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index c084075f0..271964c5a 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -423,9 +423,10 @@ struct buf_t {
*
* If <b>nulterminate</b> is true, ensure that there is a 0 byte in
* buf->head->mem right after all the data. */
-static void
+STATIC void
buf_pullup(buf_t *buf, size_t bytes, int nulterminate)
{
+ /* XXXX nothing uses nulterminate; remove it. */
chunk_t *dest, *src;
size_t capacity;
if (!buf->head)
@@ -497,6 +498,20 @@ buf_pullup(buf_t *buf, size_t bytes, int nulterminate)
check();
}
+#ifdef TOR_UNIT_TESTS
+void
+buf_get_first_chunk_data(const buf_t *buf, const char **cp, size_t *sz)
+{
+ if (!buf || !buf->head) {
+ *cp = NULL;
+ *sz = 0;
+ } else {
+ *cp = buf->head->data;
+ *sz = buf->head->datalen;
+ }
+}
+#endif
+
/** Resize buf so it won't hold extra memory that we haven't been
* using lately.
*/
@@ -551,6 +566,12 @@ buf_new(void)
return buf;
}
+size_t
+buf_get_default_chunk_size(const buf_t *buf)
+{
+ return buf->default_chunk_size;
+}
+
/** Remove all data from <b>buf</b>. */
void
buf_clear(buf_t *buf)