diff options
author | Determinant <[email protected]> | 2019-06-16 23:24:49 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-06-16 23:24:49 -0400 |
commit | 74e4246565ba5814a92ed9f84b13b17226f219d1 (patch) | |
tree | 161a15482225dce9a3940e70bfd3b5e1a50cf497 /src | |
parent | 77a765023bff4fa3d41001bdc1de9d106e35f348 (diff) |
do not free the moved pointer for C API; misc changes
Diffstat (limited to 'src')
-rw-r--r-- | src/event.cpp | 17 | ||||
-rw-r--r-- | src/msg.cpp | 4 | ||||
-rw-r--r-- | src/network.cpp | 6 | ||||
-rw-r--r-- | src/stream.cpp | 4 |
4 files changed, 21 insertions, 10 deletions
diff --git a/src/event.cpp b/src/event.cpp index 4e5ce0b..2fe2861 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -28,14 +28,22 @@ void threadcall_async_call(threadcall_t *self, threadcall_callback_t callback, v }); } -eventcontext_t *threadcall_get_ec(threadcall_t *self) { - return new eventcontext_t(self->get_ec()); +const eventcontext_t *threadcall_get_ec(const threadcall_t *self) { + return &self->get_ec(); } void sigev_free(sigev_t *self) { delete self; } void sigev_add(sigev_t *self, int signum) { self->add(signum); } +void sigev_del(sigev_t *self) { self->del(); } + +void sigev_clear(sigev_t *self) { self->clear(); } + +const eventcontext_t *sigev_get_ec(const sigev_t *self) { + return &self->get_ec(); +} + timerev_t *timerev_new(const eventcontext_t *ec, timerev_callback_t callback, void *userdata) { return new timerev_t(*ec, [=](salticidae::TimerEvent &ev) { callback(&ev, userdata); @@ -48,6 +56,11 @@ void timerev_set_callback(timerev_t *self, timerev_callback_t callback, void *us }); } + +const eventcontext_t *timerev_get_ec(const timerev_t *self) { + return &self->get_ec(); +} + void timerev_free(timerev_t *self) { delete self; } void timerev_add(timerev_t *self, double t_sec) { self->add(t_sec); } diff --git a/src/msg.cpp b/src/msg.cpp index d525cd5..be5b4b1 100644 --- a/src/msg.cpp +++ b/src/msg.cpp @@ -5,9 +5,7 @@ extern "C" { msg_t *msg_new_moved_from_bytearray(_opcode_t opcode, bytearray_t *_moved_payload) { - auto res = new msg_t(opcode, std::move(*_moved_payload)); - bytearray_free(_moved_payload); - return res; + return new msg_t(opcode, std::move(*_moved_payload)); } void msg_free(msg_t *msg) { delete msg; } diff --git a/src/network.cpp b/src/network.cpp index ef16bed..a1666ec 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -47,7 +47,7 @@ void msgnetwork_config_queue_capacity(msgnetwork_config_t *self, size_t cap) { void msgnetwork_send_msg_by_move(msgnetwork_t *self, msg_t *_moved_msg, const msgnetwork_conn_t *conn) { self->_send_msg(std::move(*_moved_msg), *conn); - delete _moved_msg; + //delete _moved_msg; } msgnetwork_conn_t *msgnetwork_connect(msgnetwork_t *self, const netaddr_t *addr, SalticidaeCError *cerror) { @@ -204,14 +204,14 @@ void peernetwork_conn_free(const peernetwork_conn_t *self) { delete self; } void peernetwork_send_msg_by_move(peernetwork_t *self, msg_t * _moved_msg, const netaddr_t *paddr) { self->_send_msg(std::move(*_moved_msg), *paddr); - delete _moved_msg; + //delete _moved_msg; } void peernetwork_multicast_msg_by_move(peernetwork_t *self, msg_t *_moved_msg, const netaddr_array_t *paddrs) { self->_multicast_msg(std::move(*_moved_msg), *paddrs); - delete _moved_msg; + //delete _moved_msg; } void peernetwork_listen(peernetwork_t *self, const netaddr_t *listen_addr, SalticidaeCError *cerror) { diff --git a/src/stream.cpp b/src/stream.cpp index 1d88785..13ee98f 100644 --- a/src/stream.cpp +++ b/src/stream.cpp @@ -51,7 +51,7 @@ bool datastream_assign_by_copy(datastream_t *dst, const datastream_t *src) { bool datastream_assign_by_move(datastream_t *dst, datastream_t *_moved_src) { try { *dst = std::move(*_moved_src); - delete _moved_src; + //delete _moved_src; } catch (...) { return false; } return true; } @@ -108,7 +108,7 @@ uint256_t *datastream_get_hash(const datastream_t *self) { bytearray_t *bytearray_new_moved_from_datastream(datastream_t *_moved_src) { try { auto res = new bytearray_t(std::move(*_moved_src)); - delete _moved_src; + //delete _moved_src; return res; } catch (...) { return nullptr; |