Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 299c45a

Browse files
Style fixes.
1 parent d478a6f commit 299c45a

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

libtelnet.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ static const size_t _buffer_sizes[] = { 0, 512, 2048, 8192, 16384, };
131131
static const size_t _buffer_sizes_count = sizeof(_buffer_sizes) /
132132
sizeof(_buffer_sizes[0]);
133133

134+
/* RFC1143 option negotiation state table allocation quantum */
135+
#define Q_BUFFER_GROWTH_QUANTUM 4
136+
134137
/* error generation function */
135138
static telnet_error_t _error(telnet_t *telnet, unsigned line,
136139
const char* func, telnet_error_t err, int fatal, const char *fmt,
@@ -328,24 +331,25 @@ static INLINE void _set_rfc1143(telnet_t *telnet, unsigned char telopt,
328331
* allows for an acceptable number of reallocations for complex code.
329332
*/
330333

331-
#define QUANTUM 4
332334
/* Did we reach the end of the table? */
333-
if (i >= telnet->q_size) {
335+
if (telnet->q_cnt >= telnet->q_size) {
334336
/* Expand the size */
335337
if ((qtmp = (telnet_rfc1143_t *)realloc(telnet->q,
336-
sizeof(telnet_rfc1143_t) * (telnet->q_size + QUANTUM))) == 0) {
338+
sizeof(telnet_rfc1143_t) *
339+
(telnet->q_size + Q_BUFFER_GROWTH_QUANTUM))) == 0) {
337340
_error(telnet, __LINE__, __func__, TELNET_ENOMEM, 0,
338341
"realloc() failed: %s", strerror(errno));
339342
return;
340343
}
341-
memset(&qtmp[telnet->q_size], 0, sizeof(telnet_rfc1143_t) * QUANTUM);
344+
memset(&qtmp[telnet->q_size], 0, sizeof(telnet_rfc1143_t) *
345+
Q_BUFFER_GROWTH_QUANTUM);
342346
telnet->q = qtmp;
343-
telnet->q_size += QUANTUM;
347+
telnet->q_size += Q_BUFFER_GROWTH_QUANTUM;
344348
}
345349
/* Add entry to end of table */
346350
telnet->q[telnet->q_cnt].telopt = telopt;
347351
telnet->q[telnet->q_cnt].state = Q_MAKE(us, him);
348-
telnet->q_cnt ++;
352+
++telnet->q_cnt;
349353
}
350354

351355
/* send negotiation bytes */

0 commit comments

Comments
 (0)