www.delorie.com/gnu/docs/gdbm/gdbm_13.html   search  
 
Buy GNU books!


gdbm

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13. Seting options.

Gdbm supports the ability to set certain options on an already open database.

 
ret = gdbm_setopt(dbf, option, value, size);

The parameters are:

GDBM_FILE dbf
The pointer returned by gdbm_open.
int option
The option to be set.
int *value
A pointer to the value to which option will be set.
int size
The length of the data pointed to by value.

The valid options are:

GDBM_CACHESIZE - Set the size of the internal bucket cache. This option may only be set once on each GDBM_FILE descriptor, and is set automatically to 100 upon the first access to the database.

GDBM_FASTMODE - Set fast mode to either on or off. This allows fast mode to be toggled on an already open and active database. value (see below) should be set to either TRUE or FALSE. This option is now obsolete.

GDBM_SYNCMODE - Turn on or off file system synchronization operations. This setting defaults to off; value (see below) should be set to either TRUE or FALSE.

GDBM_CENTFREE - Set central free block pool to either on or off. The default is off, which is how previous versions of Gdbm handled free blocks. If set, this option causes all subsequent free blocks to be placed in the global pool, allowing (in theory) more file space to be reused more quickly. value (see below) should be set to either TRUE or FALSE. NOTICE: This feature is still under study.

GDBM_COALESCEBLKS - Set free block merging to either on or off. The default is off, which is how previous versions of Gdbm handled free blocks. If set, this option causes adjacent free blocks to be merged. This can become a CPU expensive process with time, though, especially if used in conjunction with GDBM_CENTFREE. value (see below) should be set to either TRUE or FALSE. NOTICE: This feature is still under study.

The return value will be -1 upon failure, or 0 upon success. The global variable gdbm_errno will be set upon failure.

For instance, to set a database to use a cache of 10, after opening it with gdbm_open, but prior to accessing it in any way, the following code could be used:

 
int value = 10;
ret = gdbm_setopt(dbf, GDBM_CACHESIZE, &value, sizeof(int));


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003