From: Roland McGrath Date: Sat, 26 Feb 2005 01:19:02 +0000 (+0000) Subject: 2005-02-21 Jakub Jelinek X-Git-Tag: cvs/glibc-2_3_5~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8995ebd0a716749c7411612d0156492e185aa217;p=thirdparty%2Fglibc.git 2005-02-21 Jakub Jelinek [BZ #768] * nscd/hstcache.c (INCR): Remove. (addhstbyX): Double buflen in each iteration rather than add INCR. * nscd/grpcache.c: Likewise. * nscd/pwdcache.c: Likewise. --- diff --git a/nscd/grpcache.c b/nscd/grpcache.c index c565f5a6827..3cfad653e40 100644 --- a/nscd/grpcache.c +++ b/nscd/grpcache.c @@ -429,11 +429,10 @@ addgrbyX (struct database_dyn *db, int fd, request_header *req, { char *old_buffer = buffer; errno = 0; -#define INCR 1024 if (__builtin_expect (buflen > 32768, 0)) { - buflen += INCR; + buflen *= 2; buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen); if (buffer == NULL) { @@ -454,7 +453,7 @@ addgrbyX (struct database_dyn *db, int fd, request_header *req, else /* Allocate a new buffer on the stack. If possible combine it with the previously allocated buffer. */ - buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR); + buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen); } #if 0 diff --git a/nscd/hstcache.c b/nscd/hstcache.c index 99d2998f49b..754f7a66157 100644 --- a/nscd/hstcache.c +++ b/nscd/hstcache.c @@ -453,11 +453,10 @@ addhstbyX (struct database_dyn *db, int fd, request_header *req, { char *old_buffer = buffer; errno = 0; -#define INCR 1024 if (__builtin_expect (buflen > 32768, 0)) { - buflen += INCR; + buflen *= 2; buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen); if (buffer == NULL) { @@ -478,7 +477,7 @@ addhstbyX (struct database_dyn *db, int fd, request_header *req, else /* Allocate a new buffer on the stack. If possible combine it with the previously allocated buffer. */ - buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR); + buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen); } #if 0 diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c index e8b9578778d..49fc71491cc 100644 --- a/nscd/pwdcache.c +++ b/nscd/pwdcache.c @@ -425,11 +425,10 @@ addpwbyX (struct database_dyn *db, int fd, request_header *req, { char *old_buffer = buffer; errno = 0; -#define INCR 1024 if (__builtin_expect (buflen > 32768, 0)) { - buflen += INCR; + buflen *= 2; buffer = (char *) realloc (use_malloc ? buffer : NULL, buflen); if (buffer == NULL) { @@ -450,7 +449,7 @@ addpwbyX (struct database_dyn *db, int fd, request_header *req, else /* Allocate a new buffer on the stack. If possible combine it with the previously allocated buffer. */ - buffer = (char *) extend_alloca (buffer, buflen, buflen + INCR); + buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen); } #if 0