aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-08-02 13:40:19 -0400
committerNick Mathewson <nickm@torproject.org>2016-08-02 13:50:00 -0400
commit46ef4487d3914cac1aba148ec58ff271bda3c636 (patch)
tree300a4fdfb5f8714ae970fe78c9bd9beeda6c378b /src/or
parentcd9d39d54bbc9998938e9acddb1ec34507fc9108 (diff)
downloadtor-46ef4487d3914cac1aba148ec58ff271bda3c636.tar.gz
tor-46ef4487d3914cac1aba148ec58ff271bda3c636.zip
Remove generic_buffer_*() functions as needless.
These functions were there so that we could abstract the differences between evbuffer and buf_t. But with the bufferevent removal, this no longer serves a purpose.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/buffers.c4
-rw-r--r--src/or/buffers.h13
-rw-r--r--src/or/connection.c4
-rw-r--r--src/or/connection_edge.c2
-rw-r--r--src/or/or.h6
-rw-r--r--src/or/relay.c14
6 files changed, 17 insertions, 26 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 0afa3e6363..85744504a0 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -1978,8 +1978,8 @@ write_to_buf_zlib(buf_t *buf, tor_zlib_state_t *state,
/** Set *<b>output</b> to contain a copy of the data in *<b>input</b> */
int
-buf_set_to_copy(generic_buffer_t **output,
- const generic_buffer_t *input)
+buf_set_to_copy(buf_t **output,
+ const buf_t *input)
{
if (*output)
buf_free(*output);
diff --git a/src/or/buffers.h b/src/or/buffers.h
index 3629fc32c5..275867c70a 100644
--- a/src/or/buffers.h
+++ b/src/or/buffers.h
@@ -56,17 +56,8 @@ int peek_buf_has_control0_command(buf_t *buf);
int fetch_ext_or_command_from_buf(buf_t *buf, ext_or_cmd_t **out);
-#define generic_buffer_new() buf_new()
-#define generic_buffer_len(b) buf_datalen((b))
-#define generic_buffer_add(b,dat,len) write_to_buf((dat),(len),(b))
-#define generic_buffer_get(b,buf,buflen) fetch_from_buf((buf),(buflen),(b))
-#define generic_buffer_clear(b) buf_clear((b))
-#define generic_buffer_free(b) buf_free((b))
-#define generic_buffer_fetch_ext_or_cmd(b, out) \
- fetch_ext_or_command_from_buf((b), (out))
-
-int buf_set_to_copy(generic_buffer_t **output,
- const generic_buffer_t *input);
+int buf_set_to_copy(buf_t **output,
+ const buf_t *input);
void assert_buf_ok(buf_t *buf);
diff --git a/src/or/connection.c b/src/or/connection.c
index ac00a1b786..40fc2bc662 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -549,10 +549,10 @@ connection_free_(connection_t *conn)
if (entry_conn->socks_request)
socks_request_free(entry_conn->socks_request);
if (entry_conn->pending_optimistic_data) {
- generic_buffer_free(entry_conn->pending_optimistic_data);
+ buf_free(entry_conn->pending_optimistic_data);
}
if (entry_conn->sending_optimistic_data) {
- generic_buffer_free(entry_conn->sending_optimistic_data);
+ buf_free(entry_conn->sending_optimistic_data);
}
}
if (CONN_IS_EDGE(conn)) {
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 4fb195f17d..2ac82bb46e 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -2340,7 +2340,7 @@ connection_ap_handshake_send_begin(entry_connection_t *ap_conn)
log_info(LD_APP, "Sending up to %ld + %ld bytes of queued-up data",
(long)connection_get_inbuf_len(base_conn),
ap_conn->sending_optimistic_data ?
- (long)generic_buffer_len(ap_conn->sending_optimistic_data) : 0);
+ (long)buf_datalen(ap_conn->sending_optimistic_data) : 0);
if (connection_edge_package_raw_inbuf(edge_conn, 1, NULL) < 0) {
connection_mark_for_close(base_conn);
}
diff --git a/src/or/or.h b/src/or/or.h
index 3ca9ea248f..1bac43c20a 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1132,7 +1132,7 @@ typedef struct {
typedef struct buf_t buf_t;
typedef struct socks_request_t socks_request_t;
-#define generic_buffer_t buf_t
+#define buf_t buf_t
typedef struct entry_port_cfg_t {
/* Client port types (socks, dns, trans, natd) only: */
@@ -1619,11 +1619,11 @@ typedef struct entry_connection_t {
/** For AP connections only: buffer for data that we have sent
* optimistically, which we might need to re-send if we have to
* retry this connection. */
- generic_buffer_t *pending_optimistic_data;
+ buf_t *pending_optimistic_data;
/* For AP connections only: buffer for data that we previously sent
* optimistically which we are currently re-sending as we retry this
* connection. */
- generic_buffer_t *sending_optimistic_data;
+ buf_t *sending_optimistic_data;
/** If this is a DNSPort connection, this field holds the pending DNS
* request that we're going to try to answer. */
diff --git a/src/or/relay.c b/src/or/relay.c
index cfb0016913..d82ed87c16 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -1374,7 +1374,7 @@ connection_edge_process_relay_cell_not_open(
/* This is definitely a success, so forget about any pending data we
* had sent. */
if (entry_conn->pending_optimistic_data) {
- generic_buffer_free(entry_conn->pending_optimistic_data);
+ buf_free(entry_conn->pending_optimistic_data);
entry_conn->pending_optimistic_data = NULL;
}
@@ -1876,7 +1876,7 @@ connection_edge_package_raw_inbuf(edge_connection_t *conn, int package_partial,
entry_conn->sending_optimistic_data != NULL;
if (PREDICT_UNLIKELY(sending_from_optimistic)) {
- bytes_to_process = generic_buffer_len(entry_conn->sending_optimistic_data);
+ bytes_to_process = buf_datalen(entry_conn->sending_optimistic_data);
if (PREDICT_UNLIKELY(!bytes_to_process)) {
log_warn(LD_BUG, "sending_optimistic_data was non-NULL but empty");
bytes_to_process = connection_get_inbuf_len(TO_CONN(conn));
@@ -1904,9 +1904,9 @@ connection_edge_package_raw_inbuf(edge_connection_t *conn, int package_partial,
/* XXXX We could be more efficient here by sometimes packing
* previously-sent optimistic data in the same cell with data
* from the inbuf. */
- generic_buffer_get(entry_conn->sending_optimistic_data, payload, length);
- if (!generic_buffer_len(entry_conn->sending_optimistic_data)) {
- generic_buffer_free(entry_conn->sending_optimistic_data);
+ fetch_from_buf(payload, length, entry_conn->sending_optimistic_data);
+ if (!buf_datalen(entry_conn->sending_optimistic_data)) {
+ buf_free(entry_conn->sending_optimistic_data);
entry_conn->sending_optimistic_data = NULL;
}
} else {
@@ -1921,8 +1921,8 @@ connection_edge_package_raw_inbuf(edge_connection_t *conn, int package_partial,
/* This is new optimistic data; remember it in case we need to detach and
retry */
if (!entry_conn->pending_optimistic_data)
- entry_conn->pending_optimistic_data = generic_buffer_new();
- generic_buffer_add(entry_conn->pending_optimistic_data, payload, length);
+ entry_conn->pending_optimistic_data = buf_new();
+ write_to_buf(payload, length, entry_conn->pending_optimistic_data);
}
if (connection_edge_send_command(conn, RELAY_COMMAND_DATA,