summaryrefslogtreecommitdiff
path: root/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'common.c')
-rw-r--r--common.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/common.c b/common.c
index 6c5755f..bd5184c 100644
--- a/common.c
+++ b/common.c
@@ -81,11 +81,10 @@ unixtime_msec (long *msec)
static char *
resolve_relative_runtime_unique_filename (const char *filename)
{
- struct str path;
- str_init (&path);
-
const char *runtime_dir = getenv ("XDG_RUNTIME_DIR");
const char *tmpdir = getenv ("TMPDIR");
+
+ struct str path = str_make ();
if (runtime_dir && *runtime_dir == '/')
str_append (&path, runtime_dir);
else if (tmpdir && *tmpdir == '/')
@@ -726,8 +725,8 @@ socks_call_on_data (struct socks_connector *self)
if (self->read_buffer.len < to_consume)
return true;
- struct msg_unpacker unpacker;
- msg_unpacker_init (&unpacker, self->read_buffer.str, self->read_buffer.len);
+ struct msg_unpacker unpacker =
+ msg_unpacker_make (self->read_buffer.str, self->read_buffer.len);
bool result = self->on_data (self, &unpacker);
str_remove_slice (&self->read_buffer, 0, to_consume);
return result;
@@ -792,16 +791,16 @@ socks_connector_init (struct socks_connector *self, struct poller *poller)
{
memset (self, 0, sizeof *self);
- poller_fd_init (&self->socket_event, poller, (self->socket_fd = -1));
+ self->socket_event = poller_fd_make (poller, (self->socket_fd = -1));
self->socket_event.dispatcher = (poller_fd_fn) socks_connector_on_ready;
self->socket_event.user_data = self;
- poller_timer_init (&self->timeout, poller);
+ self->timeout = poller_timer_make (poller);
self->timeout.dispatcher = (poller_timer_fn) socks_connector_on_timeout;
self->timeout.user_data = self;
- str_init (&self->read_buffer);
- str_init (&self->write_buffer);
+ self->read_buffer = str_make ();
+ self->write_buffer = str_make ();
}
static void
@@ -902,8 +901,8 @@ static struct ctcp_chunk *
ctcp_chunk_new (void)
{
struct ctcp_chunk *self = xcalloc (1, sizeof *self);
- str_init (&self->tag);
- str_init (&self->text);
+ self->tag = str_make ();
+ self->text = str_make ();
return self;
}
@@ -992,8 +991,7 @@ ctcp_parse_tagged (const char *chunk, size_t len, struct ctcp_chunk *output)
static struct ctcp_chunk *
ctcp_parse (const char *message)
{
- struct str m;
- str_init (&m);
+ struct str m = str_make ();
ctcp_low_level_decode (message, &m);
struct ctcp_chunk *result = NULL, *result_tail = NULL;