From 07133ac060c2af721941f7b47c52c075df3168ba Mon Sep 17 00:00:00 2001 From: Angelo Mantellini Date: Fri, 30 Apr 2021 12:26:57 +0200 Subject: [HICN-703] Update windows-sdk and hicn code Signed-off-by: Angelo Mantellini <@ngelo.mantellini@cisco.com> Change-Id: I05e4c92ce7de3640f0272afae127e1377862bd3e Signed-off-by: Angelo Mantellini --- libtransport/src/core/rs.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'libtransport/src/core/rs.cc') diff --git a/libtransport/src/core/rs.cc b/libtransport/src/core/rs.cc index 44b5852e5..33270736d 100644 --- a/libtransport/src/core/rs.cc +++ b/libtransport/src/core/rs.cc @@ -70,8 +70,8 @@ bool BlockCode::addSymbol(const fec::buffer &packet, uint32_t i, } void BlockCode::encode() { - gf *data[n_]; - std::uint16_t old_values[k_]; + gf **data = new gf*[k_]; + uint32_t *old_values = new uint32_t[k_]; uint32_t base = operator[](0).first; // Set packet length in first 2 bytes @@ -93,9 +93,10 @@ void BlockCode::encode() { uint16_t *length = reinterpret_cast(packet->writableData()); old_values[i] = *length; - *length = htons(packet->length() - LEN_SIZE_BYTES); + *length = htons(u_short(packet->length() - LEN_SIZE_BYTES)); data[i] = packet->writableData(); + } // Finish to fill source block with the buffers to hold the repair symbols @@ -121,7 +122,7 @@ void BlockCode::encode() { TRANSPORT_LOGD("Calling encode with max_buffer_size_ = %zu", max_buffer_size_); for (uint32_t i = k_; i < n_; i++) { - fec_encode(code_, data, data[i], i, max_buffer_size_ + LEN_SIZE_BYTES); + fec_encode(code_, data, data[i], i, (int)(max_buffer_size_ + LEN_SIZE_BYTES)); } // Restore original content of buffer space used to store the length @@ -138,11 +139,13 @@ void BlockCode::encode() { TRANSPORT_LOGD("Produced repair symbol of size = %zu", packet->length()); packet->prepend(sizeof(fec_header)); } + delete [] data; + delete [] old_values; } void BlockCode::decode() { - gf *data[k_]; - uint32_t index[k_]; + gf **data = new gf*[k_]; + uint32_t *index = new uint32_t[k_]; for (uint32_t i = 0; i < k_; i++) { auto &packet = operator[](i).second; @@ -161,7 +164,7 @@ void BlockCode::decode() { packet->ensureCapacityAndFillUnused(max_buffer_size_, 0); uint16_t *length = reinterpret_cast(packet->writableData()); - *length = htons(packet->length() - LEN_SIZE_BYTES); + *length = htons(u_short(packet->length() - LEN_SIZE_BYTES)); } else { TRANSPORT_LOGD("DECODE SYMBOL - index %u - Current buffer size: %zu", index[i], packet->length()); @@ -169,12 +172,14 @@ void BlockCode::decode() { } data[i] = packet->writableData(); + delete [] data; + delete [] index; } // We decode the source block TRANSPORT_LOGD("Calling decode with max_buffer_size_ = %zu", max_buffer_size_); - fec_decode(code_, data, reinterpret_cast(index), max_buffer_size_); + fec_decode(code_, data, reinterpret_cast(index), (int)max_buffer_size_); // Find the index in the block for recovered packets for (uint32_t i = 0; i < k_; i++) { -- cgit 1.2.3-korg