From 1b2215ae2c792f96765a15c7ffcc6f20e3046cc7 Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 11 Jun 2019 01:59:04 -0400 Subject: fix slice bugs --- test_p2p_stress/main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'test_p2p_stress') diff --git a/test_p2p_stress/main.go b/test_p2p_stress/main.go index 79b28b0..4534c4f 100644 --- a/test_p2p_stress/main.go +++ b/test_p2p_stress/main.go @@ -14,7 +14,13 @@ package main // int app_id; // uint64_t addr_id; // msgnetwork_conn_t *conn; -// } timerout_callback_context_t; +// } timeout_callback_context_t; +// timeout_callback_context_t *timeout_callback_context_new() { +// timeout_callback_context_t *ctx = malloc(sizeof(timeout_callback_context_t); +// ctx->conn = NULL; +// return ctx; +// } +// import "C" import ( @@ -151,7 +157,7 @@ func onReceiveAck(_msg *C.struct_msg_t, _conn *C.struct_msgnetwork_conn_t, userd if tc.state == seg_buff_size * 2 { sendRand(tc.state, app, conn) tc.state = -1 - ctx := (*C.struct_timeout_callback_context_t)(C.malloc(C.sizeof_struct_timeout_callback_context_t)) + ctx := C.timeout_callback_context_new() ctx.app_id = C.int(id) ctx.addr_id = C.uint64_t(addr) ctx.conn = (*C.struct_msgnetwork_conn_t)(conn) -- cgit v1.2.3-70-g09d2