From: Chip Black Date: Wed, 22 Dec 2010 09:08:57 +0000 (-0600) Subject: Clean up some #defines X-Git-Tag: ohfuckreddit~47 X-Git-Url: http://git.bytex64.net/?a=commitdiff_plain;h=08a6fd7b17e7d092899dc92fb81a941b77ab9407;hp=3d6d277d4cdfff7c11729cde0e2498b4b3912a98;p=blerg.git Clean up some #defines --- 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