diff --git a/modules/channel/chain/dap_stream_ch_chain_pkt.c b/modules/channel/chain/dap_stream_ch_chain_pkt.c index e97a9cd88dae209ef37677dc7c761697753b4919..ad3e01b90e3b0ca28d61d8a71467e0684d36911c 100644 --- a/modules/channel/chain/dap_stream_ch_chain_pkt.c +++ b/modules/channel/chain/dap_stream_ch_chain_pkt.c @@ -53,22 +53,19 @@ size_t dap_stream_ch_chain_pkt_write_unsafe(dap_stream_ch_t *a_ch, uint8_t a_typ uint64_t a_chain_id, uint64_t a_cell_id, const void * a_data, size_t a_data_size) { - dap_stream_ch_chain_pkt_t * l_chain_pkt; - size_t l_chain_pkt_size = sizeof (l_chain_pkt->hdr) + a_data_size; - l_chain_pkt = DAP_NEW_Z_SIZE(dap_stream_ch_chain_pkt_t, l_chain_pkt_size ); - l_chain_pkt->hdr.version = 1; - l_chain_pkt->hdr.net_id.uint64 = a_net_id; - l_chain_pkt->hdr.cell_id.uint64 = a_cell_id; - l_chain_pkt->hdr.chain_id.uint64 = a_chain_id; + size_t l_chain_pkt_size = sizeof(dap_stream_ch_chain_pkt_hdr_t) + a_data_size; + dap_stream_ch_chain_pkt_t *l_chain_pkt = DAP_NEW_STACK_SIZE(dap_stream_ch_chain_pkt_t, l_chain_pkt_size); + *l_chain_pkt = (dap_stream_ch_chain_pkt_t){ + .hdr = { .version = 1, .net_id.uint64 = a_net_id, .cell_id.uint64 = a_cell_id, .chain_id.uint64 = a_chain_id } + }; if (a_data_size && a_data) - memcpy( l_chain_pkt->data, a_data, a_data_size); + memcpy(l_chain_pkt->data, a_data, a_data_size); - size_t l_ret = dap_stream_ch_pkt_write_unsafe(a_ch, a_type , l_chain_pkt, l_chain_pkt_size); - DAP_DELETE(l_chain_pkt); - return l_ret; + return dap_stream_ch_pkt_write_unsafe(a_ch, a_type , l_chain_pkt, l_chain_pkt_size); } + /** * @brief dap_stream_ch_chain_pkt_write_mt * @param a_worker diff --git a/modules/net/dap_chain_net.c b/modules/net/dap_chain_net.c index 16cc8769ff14f475130d6a8b3b33a47bd758f94d..fd50be0f2a50c14572c43e3c442a6a4c9ac29d0d 100644 --- a/modules/net/dap_chain_net.c +++ b/modules/net/dap_chain_net.c @@ -3380,6 +3380,7 @@ dap_list_t* dap_chain_datum_list(dap_chain_net_t *a_net, dap_chain_t *a_chain, d // go to next transaction l_atom = l_chain_cur->callback_atom_iter_get_next(l_atom_iter, &l_atom_size); } + l_chain_cur->callback_atom_iter_delete(l_atom_iter); } // Only for one chain if(a_chain) diff --git a/modules/net/dap_chain_net_tx.c b/modules/net/dap_chain_net_tx.c index cc74bc967d1e4f428a8fba7f78bc049879d128fa..dd4f0c243085de7288c0940e3dcddbe83d7f5154 100644 --- a/modules/net/dap_chain_net_tx.c +++ b/modules/net/dap_chain_net_tx.c @@ -154,6 +154,7 @@ dap_chain_datum_tx_spends_items_t * dap_chain_net_get_tx_cond_all_with_spends_by l_atom = l_chain->callback_atom_iter_get_next(l_atom_iter, &l_atom_size); } + l_chain->callback_atom_iter_delete(l_atom_iter); } } } break; @@ -240,6 +241,7 @@ void dap_chain_net_get_tx_all(dap_chain_net_t * a_net, dap_chain_net_tx_search_t // go to next atom l_atom = l_chain->callback_atom_iter_get_next(l_atom_iter, &l_atom_size); } + l_chain->callback_atom_iter_delete(l_atom_iter); } } } break; @@ -516,8 +518,8 @@ dap_list_t * dap_chain_net_get_tx_cond_all_by_srv_uid(dap_chain_net_t * a_net, c DAP_DEL_Z(l_datums); // go to next atom l_atom = l_chain->callback_atom_iter_get_next(l_atom_iter, &l_atom_size); - } + l_chain->callback_atom_iter_delete(l_atom_iter); } } } break;