Signed-off-by: Kevin Coffman <kwc@citi.umich.edu>
The readline routine expects much smaller messages than we are passing.
Change the default initial allocation and increment value from 128
to 2048. This saves many calls to realloc().
return 0;
}
+#define READLINE_BUFFER_INCREMENT 2048
+
int readline(int fd, char **buf, int *lenp)
{
/* read a line into *buf, which is malloced *len long
int len;
if (*lenp == 0) {
- char *b = malloc(128);
+ char *b = malloc(READLINE_BUFFER_INCREMENT);
if (b == NULL)
return 0;
*buf = b;
- *lenp = 128;
+ *lenp = READLINE_BUFFER_INCREMENT;
}
len = read(fd, *buf, *lenp);
if (len <= 0) {
*/
char *new;
int nl;
- *lenp += 128;
+ *lenp += READLINE_BUFFER_INCREMENT;
new = realloc(*buf, *lenp);
if (new == NULL)
return 0;