diff options
author | kwc@citi.umich.edu <kwc@citi.umich.edu> | 2006-07-03 18:34:33 -0400 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2006-07-04 10:27:15 +1000 |
commit | ee664fd246d77010af13fb557407c612752a5ea8 (patch) | |
tree | 74fe97139b5482b3f3de7bb0ebc2044c68060f35 | |
parent | 3da69ce5c4fac5677e91aa20e60750ab8de2ab97 (diff) | |
download | nfs-utils-ee664fd246d77010af13fb557407c612752a5ea8.tar.gz nfs-utils-ee664fd246d77010af13fb557407c612752a5ea8.tar.xz nfs-utils-ee664fd246d77010af13fb557407c612752a5ea8.zip |
Change default buffer size increment for readline()
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().
-rw-r--r-- | utils/gssd/cacheio.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/utils/gssd/cacheio.c b/utils/gssd/cacheio.c index ac76c06..07658e9 100644 --- a/utils/gssd/cacheio.c +++ b/utils/gssd/cacheio.c @@ -244,6 +244,8 @@ int qword_get_int(char **bpp, int *anint) 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 @@ -254,11 +256,11 @@ int readline(int fd, char **buf, int *lenp) 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) { @@ -271,7 +273,7 @@ int readline(int fd, char **buf, int *lenp) */ char *new; int nl; - *lenp += 128; + *lenp += READLINE_BUFFER_INCREMENT; new = realloc(*buf, *lenp); if (new == NULL) return 0; |