Skip to content

Commit

Permalink
* FIX [log] avoid alloc
Browse files Browse the repository at this point in the history
Signed-off-by: wayne <[email protected]>
  • Loading branch information
StargazerWayne committed Jan 10, 2024
1 parent 0113eb8 commit 4c327f7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/mqtt/transport/tcp/mqtt_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -918,8 +918,8 @@ mqtt_tcptran_pipe_send_start(mqtt_tcptran_pipe *p)

int msg_body_len = 30 < nni_msg_len(msg) ? 30 : nni_msg_len(msg);

char *strheader = nng_alloc(nni_msg_header_len(msg) * 3 + 1);
char *strbody = nng_alloc(msg_body_len * 3 + 1);
char strheader[nni_msg_header_len(msg) * 3 + 1];
char strbody[msg_body_len * 3 + 1];
char *data;

data = nni_msg_header(msg);
Expand All @@ -934,9 +934,6 @@ mqtt_tcptran_pipe_send_start(mqtt_tcptran_pipe *p)
}
log_debug("msg body: %s", strbody);

nng_free(strheader, nni_msg_header_len(msg) * 3 + 1);
nng_free(strbody, msg_body_len * 3 + 1);

nni_aio_set_iov(txaio, niov, iov);
nng_stream_send(p->conn, txaio);
}
Expand Down

0 comments on commit 4c327f7

Please sign in to comment.