Skip to content

Commit

Permalink
cleanup void * in _hashindex.c
Browse files Browse the repository at this point in the history
  • Loading branch information
motwok committed Oct 27, 2018
1 parent f8ef6af commit 9d1276a
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/borg/_hashindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef struct {
} __attribute__((__packed__)) HashHeader;

typedef struct {
void *buckets;
unsigned char *buckets;
int num_entries;
int num_buckets;
int num_empty;
Expand Down Expand Up @@ -103,10 +103,10 @@ static void hashindex_write(HashIndex *index, PyObject *file_py);

static uint64_t hashindex_compact(HashIndex *index);
static HashIndex *hashindex_init(int capacity, int key_size, int value_size);
static const void *hashindex_get(HashIndex *index, const void *key);
static int hashindex_set(HashIndex *index, const void *key, const void *value);
static int hashindex_delete(HashIndex *index, const void *key);
static void *hashindex_next_key(HashIndex *index, const void *key);
static const unsigned char *hashindex_get(HashIndex *index, const unsigned char *key);
static int hashindex_set(HashIndex *index, const unsigned char *key, const unsigned void *value);
static int hashindex_delete(HashIndex *index, const unsigned char *key);
static unsigned char *hashindex_next_key(HashIndex *index, const unsigned char *key);

/* Private API */
static void hashindex_free(HashIndex *index);
Expand All @@ -125,13 +125,13 @@ hashindex_free_buckets(HashIndex *index)
}

static int
hashindex_index(HashIndex *index, const void *key)
hashindex_index(HashIndex *index, const unsigned char *key)
{
return _le32toh(*((uint32_t *)key)) % index->num_buckets;
}

static int
hashindex_lookup(HashIndex *index, const void *key, int *start_idx)
hashindex_lookup(HashIndex *index, const unsigned char *key, int *start_idx)
{
int didx = -1;
int start = hashindex_index(index, key);
Expand Down Expand Up @@ -174,7 +174,7 @@ static int
hashindex_resize(HashIndex *index, int capacity)
{
HashIndex *new;
void *key = NULL;
unsigned char *key = NULL;
int32_t key_size = index->key_size;

if(!(new = hashindex_init(capacity, key_size, index->value_size))) {
Expand Down Expand Up @@ -355,7 +355,7 @@ hashindex_read(PyObject *file_py, int permit_compact)
index->num_buckets = _le32toh(header->num_buckets);
index->key_size = header->key_size;
index->value_size = header->value_size;
index->bucket_size = index->key_size + index->value_size;
index->bucket_size = index->key_size + index->value_size;
index->lower_limit = get_lower_limit(index->num_buckets);
index->upper_limit = get_upper_limit(index->num_buckets);

Expand Down Expand Up @@ -534,8 +534,8 @@ hashindex_write(HashIndex *index, PyObject *file_py)
}
#endif

static const void *
hashindex_get(HashIndex *index, const void *key)
static const unsigned char *
hashindex_get(HashIndex *index, const unsigned char *key)
{
int idx = hashindex_lookup(index, key, NULL);
if(idx < 0) {
Expand All @@ -545,7 +545,7 @@ hashindex_get(HashIndex *index, const void *key)
}

static int
hashindex_set(HashIndex *index, const void *key, const void *value)
hashindex_set(HashIndex *index, const unsigned char *key, const void *value)
{
int start_idx;
int idx = hashindex_lookup(index, key, &start_idx);
Expand Down Expand Up @@ -587,7 +587,7 @@ hashindex_set(HashIndex *index, const void *key, const void *value)
}

static int
hashindex_delete(HashIndex *index, const void *key)
hashindex_delete(HashIndex *index, const unsigned char *key)
{
int idx = hashindex_lookup(index, key, NULL);
if (idx < 0) {
Expand All @@ -603,8 +603,8 @@ hashindex_delete(HashIndex *index, const void *key)
return 1;
}

static void *
hashindex_next_key(HashIndex *index, const void *key)
static unsigned char *
hashindex_next_key(HashIndex *index, const unsigned char *key)
{
int idx = 0;
if(key) {
Expand Down

0 comments on commit 9d1276a

Please sign in to comment.