Skip to content

Commit 94d3aa1

Browse files
move udpard_fragment_free
1 parent 4ac88b9 commit 94d3aa1

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

libudpard/udpard.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,15 @@ static uint32_t crc_add_byte(const uint32_t crc, const byte_t byte)
129129
}
130130

131131
/// Do not forget to apply the output XOR when done, or use crc_compute().
132-
static uint32_t crc_add(const uint32_t crc, const size_t size, const void* const data)
132+
static uint32_t crc_add(uint32_t crc, const size_t size, const void* const data)
133133
{
134134
UDPARD_ASSERT((data != NULL) || (size == 0U));
135-
uint32_t out = crc;
136-
const byte_t* p = (const byte_t*)data;
135+
const byte_t* p = (const byte_t*)data;
137136
for (size_t i = 0; i < size; i++) {
138-
out = crc_add_byte(out, *p);
137+
crc = crc_add_byte(crc, *p);
139138
++p;
140139
}
141-
return out;
140+
return crc;
142141
}
143142

144143
static uint32_t crc_compute(const size_t size, const void* const data)

libudpard/udpard.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ typedef struct udpard_fragment_t
240240
udpard_mem_deleter_t payload_deleter;
241241
} udpard_fragment_t;
242242

243+
/// Frees the memory allocated for the payload and its fragment headers using the correct memory resources.
244+
/// The application can do the same thing manually if it has access to the required context to compute the size,
245+
/// or if the memory resource implementation does not require deallocation size.
246+
/// The head of the fragment list is passed by value so it is not freed. This is in line with the udpard_rx_transfer_t
247+
/// design, where the head is stored by value to reduce indirection in small transfers. We call it Scott's Head.
248+
/// If any of the arguments are NULL, the function has no effect.
249+
void udpard_fragment_free(const udpard_fragment_t head, const udpard_mem_resource_t memory_fragment);
250+
243251
// =====================================================================================================================
244252
// ================================================= TX PIPELINE =================================================
245253
// =====================================================================================================================
@@ -621,16 +629,6 @@ bool udpard_rx_new(udpard_rx_t* const self,
621629
/// The time complexity is logarithmic in the number of living sessions.
622630
void udpard_rx_poll(udpard_rx_t* const self, const udpard_microsecond_t now);
623631

624-
/// Frees the memory allocated for the payload and its fragment headers using the correct memory resources.
625-
/// The application can do the same thing manually if it has access to the required context to compute the size,
626-
/// or if the memory resource implementation does not require deallocation size.
627-
/// The head of the fragment list is passed by value so it is not freed. This is in line with the UdpardRxTransfer
628-
/// design, where the head is stored by value to reduce indirection in small transfers. We call it Scott's Head.
629-
/// If any of the arguments are NULL, the function has no effect.
630-
void udpard_rx_fragment_free(const udpard_fragment_t head,
631-
const udpard_mem_resource_t memory_fragment,
632-
const udpard_mem_deleter_t memory_payload);
633-
634632
/// To subscribe to a subject, the application should do this:
635633
/// 1. Create a new udpard_rx_subscription_t instance using udpard_rx_subscription_new().
636634
/// 2. Per redundant network interface:

0 commit comments

Comments
 (0)