/* Create and return a new buf of size 'size'
*/
-buf_t *buf_new_with_capacity(size_t size) {
+static buf_t *buf_new_with_capacity(size_t size) {
buf_t *buf;
buf = (buf_t*)tor_malloc(sizeof(buf_t));
buf->buf = (char *)tor_malloc(size);
memset(conn,0,sizeof(connection_t)); /* zero it out to start */
conn->type = type;
- if(!(conn->inbuf = buf_new()) ||
- !(conn->outbuf = buf_new()))
- return NULL;
+ conn->inbuf = buf_new();
+ conn->outbuf = buf_new();
conn->receiver_bucket = 50000; /* should be enough to do the handshake */
conn->bandwidth = conn->receiver_bucket / 10; /* give it a default */
set_socket_nonblocking(s);
conn = connection_new(type);
- if(!conn) {
- log_fn(LOG_WARNING,"connection_new failed. Giving up.");
- return -1;
- }
conn->s = s;
conn->receiver_bucket = -1; /* non-cell connections don't do receiver buckets */
conn->bandwidth = -1;
set_socket_nonblocking(news);
newconn = connection_new(new_type);
- if(!newconn) {
- log_fn(LOG_WARNING,"connection_new failed. Giving up.");
- return 0;
- }
newconn->s = news;
if(!connection_speaks_cells(newconn)) {
log_fn(LOG_DEBUG,"Creating new exit connection.");
n_stream = connection_new(CONN_TYPE_EXIT);
- if(!n_stream) {
- log_fn(LOG_WARNING,"connection_new failed. Dropping.");
- return 0;
- }
memcpy(n_stream->stream_id, cell->payload + RELAY_HEADER_SIZE, STREAM_ID_SIZE);
n_stream->address = strdup(cell->payload + RELAY_HEADER_SIZE + STREAM_ID_SIZE);
return conn;
conn = connection_new(CONN_TYPE_OR);
- if(!conn) {
- log_fn(LOG_WARNING,"connection_new failed; skipping.");
- return NULL;
- }
/* set up conn so it's got all the data we need to remember */
connection_or_init_conn_from_router(conn, router);
close(fd[1]); /* we don't need the worker's side of the pipe */
conn = connection_new(CONN_TYPE_CPUWORKER);
- if(!conn) {
- close(fd[0]);
- return -1;
- }
set_socket_nonblocking(fd[0]);
log_fn(LOG_DEBUG,"initiating directory upload");
conn = connection_new(CONN_TYPE_DIR);
- if(!conn)
- return;
/* set up conn so it's got all the data we need to remember */
conn->addr = router->addr;
close(fd[1]); /* we don't need the worker's side of the pipe */
conn = connection_new(CONN_TYPE_DNSWORKER);
- if(!conn) {
- close(fd[0]);
- return -1;
- }
set_socket_nonblocking(fd[0]);