🎈 perf(pacekt and tcp_segment init): reduce memset

This commit is contained in:
yangwei
2024-07-31 00:00:44 +08:00
committed by luwenpeng
parent 0414710399
commit 49539eb253
3 changed files with 3 additions and 9 deletions

View File

@@ -490,7 +490,7 @@ uint16_t packet_get_payload_len(const struct packet *pkt)
struct packet *packet_new(uint16_t pkt_len)
{
struct packet *pkt = (struct packet *)calloc(1, sizeof(struct packet) + pkt_len);
struct packet *pkt = (struct packet *)malloc( sizeof(struct packet) + pkt_len);
if (pkt == NULL)
{
return NULL;

View File

@@ -185,7 +185,7 @@ static void *work_thread(void *arg)
* Suggestion: After modifying the system time, restart the service to ensure consistent timing.
*/
now_ms = stellar_get_real_time_msec();
memset(packets, 0, sizeof(packets));
//memset(packets, 0, sizeof(packets));
nr_recv = packet_io_ingress(packet_io, thr_idx, packets, RX_BURST_MAX);
if (nr_recv == 0)
{

View File

@@ -32,13 +32,7 @@ struct tcp_reassembly
struct tcp_segment *tcp_segment_new(uint32_t seq, const void *data, uint32_t len)
{
struct tcp_segment_private *p = (struct tcp_segment_private *)calloc(1, sizeof(struct tcp_segment_private) + len);
if (!p)
{
TCP_REASSEMBLY_LOG_ERROR("calloc failed");
return NULL;
}
struct tcp_segment_private *p = (struct tcp_segment_private *)malloc(sizeof(struct tcp_segment_private) + len);
p->node.start = seq;
p->node.last = (uint64_t)seq + (uint64_t)len - 1;
p->data = (char *)p + sizeof(struct tcp_segment_private);