hashindex: Fix issue with indicies larger than 2GB

This commit is contained in:
Jonas Borgström 2014-11-22 14:35:51 +01:00
parent 5c699b30a7
commit 7e15abd29c
1 changed files with 3 additions and 3 deletions

View File

@ -33,10 +33,10 @@ typedef struct {
int num_buckets; int num_buckets;
int key_size; int key_size;
int value_size; int value_size;
int bucket_size; off_t bucket_size;
int lower_limit; int lower_limit;
int upper_limit; int upper_limit;
int data_len; off_t data_len;
} HashIndex; } HashIndex;
#define MAGIC "ATTICIDX" #define MAGIC "ATTICIDX"
@ -213,7 +213,7 @@ hashindex_init(int capacity, int key_size, int value_size)
EPRINTF("malloc failed"); EPRINTF("malloc failed");
return NULL; return NULL;
} }
index->data_len = sizeof(HashHeader) + capacity * (key_size + value_size); index->data_len = sizeof(HashHeader) + (off_t)capacity * (key_size + value_size);
if(!(index->data = calloc(index->data_len, 1))) { if(!(index->data = calloc(index->data_len, 1))) {
EPRINTF("malloc failed"); EPRINTF("malloc failed");
free(index); free(index);