mirror of
https://github.com/yrutschle/sslh.git
synced 2025-04-12 15:17:14 +03:00
tcp_protocol_list_init(): allocate once instead of realloc each time
This commit is contained in:
parent
ae7530e33f
commit
1ddf45bf52
@ -60,13 +60,13 @@ int probe_client_protocol(struct connection *cnx)
|
|||||||
|
|
||||||
static void tcp_protocol_list_init(void)
|
static void tcp_protocol_list_init(void)
|
||||||
{
|
{
|
||||||
|
tcp_protocols = calloc(cfg.protocols_len, sizeof(tcp_protocols));
|
||||||
|
CHECK_ALLOC(tcp_protocols, "tcp_protocols");
|
||||||
for (int i = 0; i < cfg.protocols_len; i++) {
|
for (int i = 0; i < cfg.protocols_len; i++) {
|
||||||
struct sslhcfg_protocols_item* p = &cfg.protocols[i];
|
struct sslhcfg_protocols_item* p = &cfg.protocols[i];
|
||||||
if (!p->is_udp) {
|
if (!p->is_udp) {
|
||||||
|
tcp_protocols[tcp_protocols_len] = p;
|
||||||
tcp_protocols_len++;
|
tcp_protocols_len++;
|
||||||
tcp_protocols = realloc(tcp_protocols, tcp_protocols_len * sizeof(*tcp_protocols));
|
|
||||||
CHECK_ALLOC(tcp_protocols, "realloc");
|
|
||||||
tcp_protocols[tcp_protocols_len-1] = p;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user