From 810dde21ee65653c15606917b19566cfbaaf165e Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Tue, 9 Aug 2022 21:54:45 +0200 Subject: ecp server added --- ecp/test/init.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'ecp/test/init.c') diff --git a/ecp/test/init.c b/ecp/test/init.c index f4b033a..b75b2ee 100644 --- a/ecp/test/init.c +++ b/ecp/test/init.c @@ -1,34 +1,27 @@ #include #include -#include +#include -void handle_err(ECPConnection *conn, unsigned char mtype, int err) { +static void handle_err(ECPConnection *conn, unsigned char mtype, int err) { printf("ERR: CTYPE:%d MTYPE:%x ERR:%d\n", conn->type, mtype, err); } -static ECPConnection *conn_alloc(ECPSocket *sock, unsigned char type) { +static ECPConnection *conn_new(ECPSocket *sock, unsigned char type) { ECPConnection *conn; - int rv; conn = malloc(sizeof(ECPConnection)); - if (conn == NULL) return NULL; - - rv = ecp_conn_create_inb(conn, sock, type); - if (rv) { - free(conn); - return NULL; - } + if (conn) ecp_conn_init(conn, sock, type); return conn; } static void conn_free(ECPConnection *conn) { - free(conn); + if (ecp_conn_is_gc(conn)) free(conn); } int ecp_init(ECPContext *ctx) { int rv; - rv = ecp_ctx_init(ctx, handle_err, NULL, conn_alloc, conn_free); + rv = ecp_ctx_init(ctx, handle_err, conn_new, conn_free); return rv; } -- cgit v1.2.3