summaryrefslogtreecommitdiffstats
path: root/sys/boot/ficl/dict.c
diff options
context:
space:
mode:
authordcs <dcs@FreeBSD.org>2000-05-05 02:06:38 +0000
committerdcs <dcs@FreeBSD.org>2000-05-05 02:06:38 +0000
commit64e1aa5faa0b6dbd7c0af5ae66aa3786d7d9d73e (patch)
tree3c2802f3a4cbe5a4ea1ddff0d2733f8ef424f0af /sys/boot/ficl/dict.c
parent56f09cbe0e4f66622080af18eb162b2c3c6e5957 (diff)
downloadFreeBSD-src-64e1aa5faa0b6dbd7c0af5ae66aa3786d7d9d73e.zip
FreeBSD-src-64e1aa5faa0b6dbd7c0af5ae66aa3786d7d9d73e.tar.gz
Lay the groundwork for on-demand dictionary expansion.
Diffstat (limited to 'sys/boot/ficl/dict.c')
-rw-r--r--sys/boot/ficl/dict.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/sys/boot/ficl/dict.c b/sys/boot/ficl/dict.c
index 5b19dbc..a2f5990 100644
--- a/sys/boot/ficl/dict.c
+++ b/sys/boot/ficl/dict.c
@@ -29,6 +29,11 @@
#include <string.h>
#include "ficl.h"
+/* Dictionary on-demand resizing control variables */
+unsigned int dictThreshold;
+unsigned int dictIncrease;
+
+
static char *dictCopyName(FICL_DICT *pDict, STRINGINFO si);
/**************************************************************************
@@ -347,12 +352,14 @@ FICL_DICT *dictCreateHashed(unsigned nCells, unsigned nHash)
FICL_DICT *pDict;
size_t nAlloc;
- nAlloc = sizeof (FICL_DICT) + nCells * sizeof (CELL)
- + sizeof (FICL_HASH) + (nHash - 1) * sizeof (FICL_WORD *);
+ nAlloc = sizeof (FICL_HASH) + nCells * sizeof (CELL)
+ + (nHash - 1) * sizeof (FICL_WORD *);
- pDict = ficlMalloc(nAlloc);
+ pDict = ficlMalloc(sizeof (FICL_DICT));
assert(pDict);
memset(pDict, 0, sizeof (FICL_DICT));
+ pDict->dict = ficlMalloc(nAlloc);
+ assert(pDict->dict);
pDict->size = nCells;
dictEmpty(pDict, nHash);
return pDict;
@@ -701,4 +708,19 @@ void hashReset(FICL_HASH *pHash)
return;
}
+/**************************************************************************
+ d i c t C h e c k T h r e s h o l d
+** Verify if an increase in the dictionary size is warranted, and do it if
+** so.
+**************************************************************************/
+
+void dictCheckThreshold(FICL_DICT* dp)
+{
+ if( dictCellsAvail(dp) < dictThreshold ) {
+ dp->dict = ficlMalloc( dictIncrease * sizeof (CELL) );
+ assert(dp->dict);
+ dp->here = dp->dict;
+ dp->size = dictIncrease;
+ }
+}
OpenPOWER on IntegriCloud