From 91b1fb7ff7fe6103b6d9f9073fa8bd056c114524 Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Sat, 11 Jun 2005 21:17:38 +0000 Subject: some more cleaning and docing svn:r4415 --- src/or/buffers.c | 45 +++++++++++++++++++++++---------------------- src/or/circuitbuild.c | 7 ++++++- 2 files changed, 29 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/or/buffers.c b/src/or/buffers.c index d194f0a8f..b0c3d912a 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -303,8 +303,7 @@ buf_shrink(buf_t *buf) buf_resize(buf, new_len); } -/** Remove the first n bytes from buf. - */ +/** Remove the first n bytes from buf. */ static INLINE void buf_remove_from_front(buf_t *buf, size_t n) { tor_assert(buf->datalen >= n); @@ -329,8 +328,7 @@ buf_nul_terminate(buf_t *buf) return 0; } -/** Create and return a new buf with capacity size. - */ +/** Create and return a new buf with capacity size. */ buf_t * buf_new_with_capacity(size_t size) { buf_t *buf; @@ -352,7 +350,7 @@ buf_new(void) return buf_new_with_capacity(INITIAL_BUF_SIZE); } -/** Remove all data from buf */ +/** Remove all data from buf. */ void buf_clear(buf_t *buf) { @@ -376,16 +374,15 @@ buf_capacity(const buf_t *buf) return buf->len; } -/** For testing only: Return a pointer to the raw memory stored in buf. - */ +/** For testing only: Return a pointer to the raw memory stored in + * buf. */ const char * _buf_peek_raw_buffer(const buf_t *buf) { return buf->cur; } -/** Release storage held by buf. - */ +/** Release storage held by buf. */ void buf_free(buf_t *buf) { @@ -397,7 +394,7 @@ buf_free(buf_t *buf) tor_free(buf); } -/** Helper for read_to_buf: read no more than at_most bytes from +/** Helper for read_to_buf(): read no more than at_most bytes from * socket s into buffer buf, starting at the position pos. (Does not * check for overflow.) Set *reached_eof to true on EOF. Return * number of bytes read on success, 0 if the read would block, -1 on @@ -434,7 +431,7 @@ read_to_buf_impl(int s, size_t at_most, buf_t *buf, /** Read from socket s, writing onto end of buf. Read at most * at_most bytes, resizing the buffer as necessary. If recv() - * returns 0, set *reached_eof to 1 and return 0. Return -1 on error; + * returns 0, set *reached_eof to 1 and return 0. Return -1 on error; * else return the number of bytes read. Return 0 if recv() would * block. */ @@ -481,10 +478,11 @@ read_to_buf(int s, size_t at_most, buf_t *buf, int *reached_eof) return r; } -/** Helper for read_to_buf_tls: read no more than at_most bytes from - * the TLS connection tlsinto buffer buf, starting at the position - * next. (Does not check for overflow.) Return number of bytes read - * on success, 0 if the read would block, -1 on failure. +/** Helper for read_to_buf_tls(): read no more than at_most + * bytes from the TLS connection tls into buffer buf, + * starting at the position next. (Does not check for overflow.) + * Return number of bytes read on success, 0 if the read would block, + * -1 on failure. */ static INLINE int read_to_buf_tls_impl(tor_tls *tls, size_t at_most, buf_t *buf, char *next) @@ -569,8 +567,9 @@ read_to_buf_tls(tor_tls *tls, size_t at_most, buf_t *buf) return r; } -/** Helper for flush_buf: try to write sz bytes from buffer buf onto - * socket s. On success, deduct the bytes written from *buf_flushlen. +/** Helper for flush_buf(): try to write sz bytes from buffer + * buf onto socket s. On success, deduct the bytes written + * from *buf_flushlen. * Return the number of bytes written on success, -1 on failure. */ static INLINE int @@ -596,7 +595,7 @@ flush_buf_impl(int s, buf_t *buf, size_t sz, size_t *buf_flushlen) } /** Write data from buf to the socket s. Write at most - * *buf_flushlen bytes, decrement *buf_flushlen by + * *buf_flushlen bytes, decrement *buf_flushlen by * the number of bytes actually written, and remove the written bytes * from the buffer. Return the number of bytes written on success, * -1 on failure. Return 0 if write() would block. @@ -641,8 +640,9 @@ flush_buf(int s, buf_t *buf, size_t *buf_flushlen) return flushed; } -/** Helper for flush_buf_tls: try to write sz bytes from buffer buf onto - * TLS object tls. On success, deduct the bytes written from *buf_flushlen. +/** Helper for flush_buf_tls(): try to write sz bytes from buffer + * buf onto TLS object tls. On success, deduct the bytes + * written from *buf_flushlen. * Return the number of bytes written on success, -1 on failure. */ static INLINE int @@ -661,7 +661,7 @@ flush_buf_tls_impl(tor_tls *tls, buf_t *buf, size_t sz, size_t *buf_flushlen) return r; } -/** As flush_buf, but writes data to a TLS connection. +/** As flush_buf(), but writes data to a TLS connection. */ int flush_buf_tls(tor_tls *tls, buf_t *buf, size_t *buf_flushlen) { @@ -740,7 +740,8 @@ write_to_buf(const char *string, size_t string_len, buf_t *buf) return buf->datalen; } -/** Helper: copy the first string_len bytes from buf onto string. +/** Helper: copy the first string_len bytes from buf + * onto string. */ static INLINE void peek_from_buf(char *string, size_t string_len, buf_t *buf) diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c index 704fd8fac..64bcfb1b9 100644 --- a/src/or/circuitbuild.c +++ b/src/or/circuitbuild.c @@ -400,7 +400,12 @@ circuit_n_conn_done(connection_t *or_conn, int status) } } -/** DOCDOC */ +/** Find a new circid that isn't currently in use by the outgoing + * circuit circ, and deliver a cell of type cell_type + * (either CELL_CREATE or CELL_CREATE_FAST) with payload payload + * to this circuit. + * Return -1 if we failed to find a suitable circid, else return 0. + */ static int circuit_deliver_create_cell(circuit_t *circ, uint8_t cell_type, char *payload) { -- cgit v1.2.3