mirror of https://gerrit.osmocom.org/libtelnet
grow the rfc1143 array by 4 elements instead of 1
This commit is contained in:
parent
b10946c96d
commit
1e80f52f80
|
@ -236,7 +236,10 @@ static INLINE void _set_rfc1143(telnet_t *telnet, unsigned char telopt,
|
|||
}
|
||||
|
||||
/* we're going to need to track state for it, so grow the queue
|
||||
* and put the telopt into it; bail on allocation error
|
||||
* by 4 (four) elements and put the telopt into it; bail on allocation
|
||||
* error. we go by four because it seems like a reasonable guess as
|
||||
* to the number of enabled options for most simple code, and it
|
||||
* allows for an acceptable number of reallocations for complex code.
|
||||
*/
|
||||
if ((qtmp = (telnet_rfc1143_t *)realloc(telnet->q, sizeof(
|
||||
telnet_rfc1143_t) * (telnet->q_size + 1))) == 0) {
|
||||
|
@ -244,6 +247,7 @@ static INLINE void _set_rfc1143(telnet_t *telnet, unsigned char telopt,
|
|||
"malloc() failed: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
memset(&qtmp[telnet->q_size], 0, sizeof(telnet_rfc1143_t *) * 4);
|
||||
telnet->q = qtmp;
|
||||
telnet->q[telnet->q_size].telopt = telopt;
|
||||
telnet->q[telnet->q_size].us = us;
|
||||
|
|
Loading…
Reference in New Issue