#include #include "connection.h" connection_t* create_connection(conntype_e type){ connection_t* conn = malloc(sizeof(connection_t)); if(NULL == conn) { printf("create_connection: malloc failed\n"); } else { conn->type = type; conn->fd = -1; } return conn; } int destroy_connection(connection_t* conn) { int err = 0; if(NULL != conn) { if(-1 != conn->fd) { err = close(conn->fd); if(-1 == err) { printf("destroy_connection: close connection failed"); } } free(conn); } return err; }