summaryrefslogtreecommitdiff
path: root/ecp/test/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'ecp/test/init.c')
-rw-r--r--ecp/test/init.c19
1 files changed, 6 insertions, 13 deletions
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 <stdlib.h>
#include <stdio.h>
-#include <core.h>
+#include <ecp/core.h>
-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;
}