diff options
-rw-r--r-- | doc/gdbm.texi | 19 | ||||
-rw-r--r-- | src/gdbmtool.c | 15 | ||||
-rw-r--r-- | src/var.c | 2 |
3 files changed, 35 insertions, 1 deletions
diff --git a/doc/gdbm.texi b/doc/gdbm.texi index 8920839..ed57243 100644 --- a/doc/gdbm.texi +++ b/doc/gdbm.texi @@ -2238,12 +2238,31 @@ Setting this variable to false or unsetting it results in passing @deftypevr {gdbmtool variable} bool sync Flush all database writes on disk immediately. Default is false. @xref{Open, GDBM_SYNC}. @end deftypevr +@deftypevr {gdbmtool variable} bool coalesce +Enables the @emph{coalesce} mode, i.e. merging of the freed blocks of +GDBM files with entries in available block lists. This provides for +effective memory management at the cost of slight increase in +execution time when calling @code{gdbm_delete}. @xref{Options, +GDBM_SETCOALESCEBLKS}. + +This variable affects the @command{open} command and should be set +before invoking it. +@end deftypevr + +@deftypevr {gdbmtool variable} bool centfree +Set to @samp{true}, enables the use of central free block pool in +newly opened databases. @xref{Options, GDBM_SETCOALESCEBLKS}. + +This variable affects the @command{open} command and should be set +before invoking it. +@end deftypevr + The following commands are used to list or modify the variables: @deffn {command verb} set [@var{assignments}] When used without arguments, lists all variables and their values. Unset variables are shown after a comment sign (@samp{#}). For string and numeric variables, values are shown after an equals sign. For diff --git a/src/gdbmtool.c b/src/gdbmtool.c index e99547d..5ae668c 100644 --- a/src/gdbmtool.c +++ b/src/gdbmtool.c @@ -84,13 +84,13 @@ opendb (char *dbname) if (!variable_is_true ("lock")) flags |= GDBM_NOLOCK; if (!variable_is_true ("mmap")) flags |= GDBM_NOMMAP; if (variable_is_true ("sync")) flags |= GDBM_SYNC; - + if (open_mode == GDBM_NEWDB) { if (interactive () && variable_is_true ("confirm") && access (dbname, F_OK) == 0) { if (!getyn (_("database %s already exists; overwrite"), dbname)) @@ -111,12 +111,25 @@ opendb (char *dbname) } if (cache_size && gdbm_setopt (db, GDBM_CACHESIZE, &cache_size, sizeof (int)) == -1) terror (_("gdbm_setopt failed: %s"), gdbm_strerror (gdbm_errno)); + if (variable_is_true ("coalesce")) + { + int t = 1; + if (gdbm_setopt (db, GDBM_SETCOALESCEBLKS, &t, sizeof (t)) == -1) + terror (_("gdbm_setopt failed: %s"), gdbm_strerror (gdbm_errno)); + } + if (variable_is_true ("centfree")) + { + int t = 1; + if (gdbm_setopt (db, GDBM_SETCENTFREE, &t, sizeof (t)) == -1) + terror (_("gdbm_setopt failed: %s"), gdbm_strerror (gdbm_errno)); + } + if (gdbm_file) gdbm_close (gdbm_file); gdbm_file = db; return 0; } @@ -56,12 +56,14 @@ static struct variable vartab[] = { { "cachesize", VART_INT, VARF_DFL }, { "blocksize", VART_INT, VARF_DFL }, { "open", VART_STRING, VARF_DFL, { NULL }, open_hook }, { "lock", VART_BOOL, VARF_INIT, { .bool = 1 } }, { "mmap", VART_BOOL, VARF_INIT, { .bool = 1 } }, { "sync", VART_BOOL, VARF_INIT, { .bool = 0 } }, + { "coalesce", VART_BOOL, VARF_INIT, { .bool = 0 } }, + { "centfree", VART_BOOL, VARF_INIT, { .bool = 0 } }, { "filemode", VART_INT, VARF_INIT|VARF_OCTAL|VARF_PROT, { .num = 0644 } }, { "pager", VART_STRING, VARF_DFL }, { "quiet", VART_BOOL, VARF_DFL }, { NULL } }; |