2 * UCW Library -- Fast Database Management Routines -- Internal Declarations
4 * (c) 1999--2001 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
10 #define SDBM_NUM_FREE_PAGE_POOLS 32
12 struct sdbm_root { /* Must fit in 1K which is minimum page size */
15 u32 page_order; /* Binary logarithm of page size */
16 s32 key_size; /* Key/val size, -1=variable */
18 u32 dir_start; /* First page of the page directory */
19 u32 dir_order; /* Binary logarithm of directory size */
21 * As we know the only thing which can be freed is the page directory
22 * and it can grow only a limited number of times, we can use a very
23 * simple-minded representation of the free page pool. We also assume
24 * these entries are sorted by start position.
29 } free_pool[SDBM_NUM_FREE_PAGE_POOLS];
33 u32 used; /* Bytes used in this bucket */
38 struct page_cache *cache;
40 struct sdbm_root *root;
41 struct page *root_page;
42 int key_size; /* Cached values from root page */
46 uns page_mask; /* page_size - 1 */
47 uns dir_size; /* Page directory size in entries */
48 uns dir_shift; /* Number of significant bits of hash function */
49 uns file_size; /* in pages */
51 uns find_page, find_pos; /* Current pointer for sdbm_find_next() */
52 uns find_free_list; /* First free list entry not skipped by sdbm_find_next() */
55 #define SDBM_MAGIC 0x5344424d
56 #define SDBM_VERSION 2
58 #define GET32(p,o) *((u32 *)((p)+(o)))