From f425cf833852c4e1b4660cbba6190d04b070f6b6 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sat, 4 Jan 2014 13:30:56 -0500 Subject: Start writing tests for 10169. Now we cover more chunk allocation functions. --- src/or/buffers.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/or/buffers.c') 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 nulterminate 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 buf. */ void buf_clear(buf_t *buf) -- cgit v1.2.3