aboutsummaryrefslogtreecommitdiff
path: root/src/gdbmdefs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gdbmdefs.h')
-rw-r--r--src/gdbmdefs.h17
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 @@
#define DEFAULT_TEXT_DOMAIN PACKAGE
#include "gettext.h"
#define _(s) gettext (s)
#define N_(s) s
+/* The width in bits of the integer type or expression T. */
+#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
+
+#define SIGNED_TYPE_MAXIMUM(t) \
+ ((t) ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1))
+
+/* Maximum value for off_t */
+#define OFF_T_MAX SIGNED_TYPE_MAXIMUM (off_t)
+
+/* Return true if A can be added to B without integer overflow */
+static inline off_t
+off_t_sum_ok (off_t a, off_t b)
+{
+ return OFF_T_MAX - a >= b;
+}
+
/* The type definitions are next. */
/* The available file space is stored in an "avail" table. The one with
most activity is contained in the file header. (See below.) When that
one filles up, it is split in half and half is pushed on an "avail
stack." When the active avail table is empty and the "avail stack" is
@@ -90,12 +106,13 @@ typedef struct
off_t data_pointer; /* The file address of the key record. The
data record directly follows the key. */
int key_size; /* Size of key data in the file. */
int data_size; /* Size of associated data in the file. */
} bucket_element;
+extern int gdbm_bucket_element_valid_p (GDBM_FILE dbf, int elem_loc);
/* A bucket is a small hash table. This one consists of a number of
bucket elements plus some bookkeeping fields. The number of elements
depends on the optimum blocksize for the storage device and on a
parameter given at file creation time. This bucket takes one block.
When one of these tables gets full, it is split into two hash buckets.

Return to:

Send suggestions and report system problems to the System administrator.