mirror of
https://github.com/borgbackup/borg.git
synced 2024-12-26 17:57:59 +00:00
cleanup void * in _hashindex.c
This commit is contained in:
parent
f8ef6af454
commit
9d1276af04
1 changed files with 15 additions and 15 deletions
|
@ -34,7 +34,7 @@ typedef struct {
|
||||||
} __attribute__((__packed__)) HashHeader;
|
} __attribute__((__packed__)) HashHeader;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *buckets;
|
unsigned char *buckets;
|
||||||
int num_entries;
|
int num_entries;
|
||||||
int num_buckets;
|
int num_buckets;
|
||||||
int num_empty;
|
int num_empty;
|
||||||
|
@ -103,10 +103,10 @@ static void hashindex_write(HashIndex *index, PyObject *file_py);
|
||||||
|
|
||||||
static uint64_t hashindex_compact(HashIndex *index);
|
static uint64_t hashindex_compact(HashIndex *index);
|
||||||
static HashIndex *hashindex_init(int capacity, int key_size, int value_size);
|
static HashIndex *hashindex_init(int capacity, int key_size, int value_size);
|
||||||
static const void *hashindex_get(HashIndex *index, const void *key);
|
static const unsigned char *hashindex_get(HashIndex *index, const unsigned char *key);
|
||||||
static int hashindex_set(HashIndex *index, const void *key, const void *value);
|
static int hashindex_set(HashIndex *index, const unsigned char *key, const unsigned void *value);
|
||||||
static int hashindex_delete(HashIndex *index, const void *key);
|
static int hashindex_delete(HashIndex *index, const unsigned char *key);
|
||||||
static void *hashindex_next_key(HashIndex *index, const void *key);
|
static unsigned char *hashindex_next_key(HashIndex *index, const unsigned char *key);
|
||||||
|
|
||||||
/* Private API */
|
/* Private API */
|
||||||
static void hashindex_free(HashIndex *index);
|
static void hashindex_free(HashIndex *index);
|
||||||
|
@ -125,13 +125,13 @@ hashindex_free_buckets(HashIndex *index)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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;
|
return _le32toh(*((uint32_t *)key)) % index->num_buckets;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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 didx = -1;
|
||||||
int start = hashindex_index(index, key);
|
int start = hashindex_index(index, key);
|
||||||
|
@ -174,7 +174,7 @@ static int
|
||||||
hashindex_resize(HashIndex *index, int capacity)
|
hashindex_resize(HashIndex *index, int capacity)
|
||||||
{
|
{
|
||||||
HashIndex *new;
|
HashIndex *new;
|
||||||
void *key = NULL;
|
unsigned char *key = NULL;
|
||||||
int32_t key_size = index->key_size;
|
int32_t key_size = index->key_size;
|
||||||
|
|
||||||
if(!(new = hashindex_init(capacity, key_size, index->value_size))) {
|
if(!(new = hashindex_init(capacity, key_size, index->value_size))) {
|
||||||
|
@ -355,7 +355,7 @@ hashindex_read(PyObject *file_py, int permit_compact)
|
||||||
index->num_buckets = _le32toh(header->num_buckets);
|
index->num_buckets = _le32toh(header->num_buckets);
|
||||||
index->key_size = header->key_size;
|
index->key_size = header->key_size;
|
||||||
index->value_size = header->value_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->lower_limit = get_lower_limit(index->num_buckets);
|
||||||
index->upper_limit = get_upper_limit(index->num_buckets);
|
index->upper_limit = get_upper_limit(index->num_buckets);
|
||||||
|
|
||||||
|
@ -534,8 +534,8 @@ hashindex_write(HashIndex *index, PyObject *file_py)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const void *
|
static const unsigned char *
|
||||||
hashindex_get(HashIndex *index, const void *key)
|
hashindex_get(HashIndex *index, const unsigned char *key)
|
||||||
{
|
{
|
||||||
int idx = hashindex_lookup(index, key, NULL);
|
int idx = hashindex_lookup(index, key, NULL);
|
||||||
if(idx < 0) {
|
if(idx < 0) {
|
||||||
|
@ -545,7 +545,7 @@ hashindex_get(HashIndex *index, const void *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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 start_idx;
|
||||||
int idx = hashindex_lookup(index, key, &start_idx);
|
int idx = hashindex_lookup(index, key, &start_idx);
|
||||||
|
@ -587,7 +587,7 @@ hashindex_set(HashIndex *index, const void *key, const void *value)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
hashindex_delete(HashIndex *index, const void *key)
|
hashindex_delete(HashIndex *index, const unsigned char *key)
|
||||||
{
|
{
|
||||||
int idx = hashindex_lookup(index, key, NULL);
|
int idx = hashindex_lookup(index, key, NULL);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
|
@ -603,8 +603,8 @@ hashindex_delete(HashIndex *index, const void *key)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static unsigned char *
|
||||||
hashindex_next_key(HashIndex *index, const void *key)
|
hashindex_next_key(HashIndex *index, const unsigned char *key)
|
||||||
{
|
{
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
if(key) {
|
if(key) {
|
||||||
|
|
Loading…
Reference in a new issue