#include "connection.h" #include #include #include #include #include /// Creates new connection. /// \param client File descriptor of client's socket /// \return Pointer to connection or NULL if an error occured struct connection * connection_new(const int client) { struct connection * c = malloc(sizeof(struct connection)); if (NULL == c) { return NULL; } memset(c, 0, sizeof(struct connection)); c->fd = client; c->ref = LUA_NOREF; c->L = NULL; c->push = 0; return c; } /// Frees all resources associated with the connection. /// \param c Connection to free void connection_free(struct connection * c) { close(c->fd); // TODO: Check for errors in close()? free(c); }