From 231887cbb4d7e3c3fb3117cd9ef89a69b2e1d0dc Mon Sep 17 00:00:00 2001 From: jdolecek Date: Mon, 14 May 2001 21:45:19 +0000 Subject: [PATCH] Bump the initial record buffer size to 1MB and allow it to grow to 8MB, if needed and record count is within bounds (length) + sizeof(TRECHEADER)); } - if (c == BUFFEND && nelem < min(9, MAXNUM)) { + if (c == BUFFEND && nelem < MAXNUM + && bufsize < MAXBUFSIZE) { const u_char **keyp; u_char *oldb = buffer; diff --git a/usr.bin/sort/fsort.h b/usr.bin/sort/fsort.h index 389eb5e28266..41a755757cc5 100644 --- a/usr.bin/sort/fsort.h +++ b/usr.bin/sort/fsort.h @@ -1,4 +1,4 @@ -/* $NetBSD: fsort.h,v 1.8 2001/02/19 20:50:17 jdolecek Exp $ */ +/* $NetBSD: fsort.h,v 1.9 2001/05/14 21:45:20 jdolecek Exp $ */ /*- * Copyright (c) 1993 @@ -39,11 +39,19 @@ */ #define BUFSIZE (1<<20) -#define MAXNUM (BUFSIZE/10) /* low guess at average record size */ +#define MAXNUM 131072 /* low guess at average record count */ #define BUFFEND (EOF-2) #define MAXFCT 1000 #define DEFLLEN 65536 +/* + * Default (initial) and maximum size of record buffer for fsort(). + * Note that no more than MAXNUM records are stored in the buffer, + * even if the buffer is not full yet. + */ +#define DEFBUFSIZE (1 << 20) /* 1MB */ +#define MAXBUFSIZE (8 << 20) /* 10 MB */ + /* * Number of files merge() can merge in one pass. * This should be power of two so that it's possible to use this value