diff options
Diffstat (limited to 'src/gdbmdefs.h')
-rw-r--r-- | src/gdbmdefs.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gdbmdefs.h b/src/gdbmdefs.h index 5305b0d..1bb519b 100644 --- a/src/gdbmdefs.h +++ b/src/gdbmdefs.h | |||
@@ -23,12 +23,28 @@ | |||
23 | #define DEFAULT_TEXT_DOMAIN PACKAGE | 23 | #define DEFAULT_TEXT_DOMAIN PACKAGE |
24 | #include "gettext.h" | 24 | #include "gettext.h" |
25 | 25 | ||
26 | #define _(s) gettext (s) | 26 | #define _(s) gettext (s) |
27 | #define N_(s) s | 27 | #define N_(s) s |
28 | 28 | ||
29 | /* The width in bits of the integer type or expression T. */ | ||
30 | #define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT) | ||
31 | |||
32 | #define SIGNED_TYPE_MAXIMUM(t) \ | ||
33 | ((t) ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)) | ||
34 | |||
35 | /* Maximum value for off_t */ | ||
36 | #define OFF_T_MAX SIGNED_TYPE_MAXIMUM (off_t) | ||
37 | |||
38 | /* Return true if A can be added to B without integer overflow */ | ||
39 | static inline off_t | ||
40 | off_t_sum_ok (off_t a, off_t b) | ||
41 | { | ||
42 | return OFF_T_MAX - a >= b; | ||
43 | } | ||
44 | |||
29 | /* The type definitions are next. */ | 45 | /* The type definitions are next. */ |
30 | 46 | ||
31 | /* The available file space is stored in an "avail" table. The one with | 47 | /* The available file space is stored in an "avail" table. The one with |
32 | most activity is contained in the file header. (See below.) When that | 48 | most activity is contained in the file header. (See below.) When that |
33 | one filles up, it is split in half and half is pushed on an "avail | 49 | one filles up, it is split in half and half is pushed on an "avail |
34 | stack." When the active avail table is empty and the "avail stack" is | 50 | stack." When the active avail table is empty and the "avail stack" is |
@@ -90,12 +106,13 @@ typedef struct | |||
90 | off_t data_pointer; /* The file address of the key record. The | 106 | off_t data_pointer; /* The file address of the key record. The |
91 | data record directly follows the key. */ | 107 | data record directly follows the key. */ |
92 | int key_size; /* Size of key data in the file. */ | 108 | int key_size; /* Size of key data in the file. */ |
93 | int data_size; /* Size of associated data in the file. */ | 109 | int data_size; /* Size of associated data in the file. */ |
94 | } bucket_element; | 110 | } bucket_element; |
95 | 111 | ||
112 | extern int gdbm_bucket_element_valid_p (GDBM_FILE dbf, int elem_loc); | ||
96 | 113 | ||
97 | /* A bucket is a small hash table. This one consists of a number of | 114 | /* A bucket is a small hash table. This one consists of a number of |
98 | bucket elements plus some bookkeeping fields. The number of elements | 115 | bucket elements plus some bookkeeping fields. The number of elements |
99 | depends on the optimum blocksize for the storage device and on a | 116 | depends on the optimum blocksize for the storage device and on a |
100 | parameter given at file creation time. This bucket takes one block. | 117 | parameter given at file creation time. This bucket takes one block. |
101 | When one of these tables gets full, it is split into two hash buckets. | 118 | When one of these tables gets full, it is split into two hash buckets. |