Commit 8775d418 authored by Lubomir Bulej's avatar Lubomir Bulej
Browse files

Extract connection allocation into __connection_alloc()

parent 5db2918b
......@@ -21,6 +21,13 @@
//
static inline struct connection *
__connection_alloc () {
struct connection * connection = malloc (sizeof (struct connection));
check_error (connection == NULL, "failed to allocate connection structure");
return connection;
}
static void
__connection_init (struct connection * connection, const int sockfd) {
connection->sockfd = sockfd;
......@@ -61,10 +68,7 @@ connection_open (struct addrinfo * addr) {
//
struct connection * connection =
(struct connection *) malloc (sizeof (struct connection));
check_error (connection == NULL, "failed to allocate connection structure");
struct connection * connection = __connection_alloc ();
__connection_init (connection, sockfd);
return connection;
}
......
......@@ -19,6 +19,13 @@
//
static inline struct connection *
__connection_alloc () {
struct connection * connection = malloc (sizeof (struct connection));
check_error (connection == NULL, "failed to allocate connection structure");
return connection;
}
static void
__connection_init (struct connection * connection, const int sockfd) {
connection->sockfd = sockfd;
......@@ -58,10 +65,7 @@ connection_open (struct addrinfo * addr) {
//
struct connection * connection =
(struct connection *) malloc (sizeof (struct connection));
check_error (connection == NULL, "failed to allocate connection structure");
struct connection * connection = __connection_alloc ();
__connection_init (connection, sockfd);
return connection;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment