From 08a6fd7b17e7d092899dc92fb81a941b77ab9407 Mon Sep 17 00:00:00 2001 From: Chip Black Date: Wed, 22 Dec 2010 03:08:57 -0600 Subject: [PATCH] Clean up some #defines --- config.h | 3 +++ database.c | 6 ++---- database.h | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config.h b/config.h index 726792e..80327ca 100644 --- a/config.h +++ b/config.h @@ -5,4 +5,7 @@ #define HASH_TAGS_PATH "hash_tags" #define AUTHOR_TAGS_PATH "author_tags" +#define RECORDS_PER_SEGMENT 65536 +#define MAX_RECORD_SIZE 65535 /* No greater than 65535 */ + #endif //_CONFIG_H diff --git a/database.c b/database.c index c3ac954..4b16d32 100644 --- a/database.c +++ b/database.c @@ -11,8 +11,6 @@ #include "database.h" #include "config.h" -#define RECORDS_PER_SEGMENT 65536 - uint64_t blerg_get_record_count(struct blerg *blerg) { uint64_t count; flock(blerg->meta_fd, LOCK_SH); @@ -101,7 +99,7 @@ int blerg_segment_switch(struct blerg *blerg, int new_segment) { open_failed_data_mmap: close(blerg->data_fd); open_failed_data_open: - munmap((void *)blerg->index, sizeof(65536 * sizeof(struct record))); + munmap((void *)blerg->index, sizeof(RECORDS_PER_SEGMENT * sizeof(struct record))); open_failed_index_mmap: close(blerg->index_fd); open_failed_index_open: @@ -203,7 +201,7 @@ int blerg_close(struct blerg *blerg) { } int blerg_store(struct blerg *blerg, const char *data, int len) { - if (len > 65536) { + if (len > MAX_RECORD_SIZE) { printf("len > 64K\n"); return -1; } diff --git a/database.h b/database.h index ab5cb97..ed9707d 100644 --- a/database.h +++ b/database.h @@ -31,5 +31,6 @@ struct blerg *blerg_open(const char *); int blerg_close(struct blerg *); int blerg_store(struct blerg *, const char *, int); int blerg_fetch(struct blerg *, int, char **, int *); +uint64_t blerg_get_record_count(struct blerg *); #endif //_DATABASE_H -- 2.34.1