mirror of https://github.com/xzeldon/htop.git
Hashtable: use more distinct typename for key type
This commit is contained in:
parent
43d5c61884
commit
8fe04b7494
2
Action.c
2
Action.c
|
@ -104,7 +104,7 @@ static bool changePriority(MainPanel* panel, int delta) {
|
||||||
return anyTagged;
|
return anyTagged;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addUserToVector(hkey_t key, void* userCast, void* panelCast) {
|
static void addUserToVector(ht_key_t key, void* userCast, void* panelCast) {
|
||||||
const char* user = userCast;
|
const char* user = userCast;
|
||||||
Panel* panel = panelCast;
|
Panel* panel = panelCast;
|
||||||
Panel_add(panel, (Object*) ListItem_new(user, key));
|
Panel_add(panel, (Object*) ListItem_new(user, key));
|
||||||
|
|
|
@ -124,7 +124,7 @@ void Hashtable_clear(Hashtable* this) {
|
||||||
assert(Hashtable_isConsistent(this));
|
assert(Hashtable_isConsistent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void insert(Hashtable* this, hkey_t key, void* value) {
|
static void insert(Hashtable* this, ht_key_t key, void* value) {
|
||||||
unsigned int index = key % this->size;
|
unsigned int index = key % this->size;
|
||||||
unsigned int probe = 0;
|
unsigned int probe = 0;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -194,7 +194,7 @@ void Hashtable_setSize(Hashtable* this, unsigned int size) {
|
||||||
assert(Hashtable_isConsistent(this));
|
assert(Hashtable_isConsistent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hashtable_put(Hashtable* this, hkey_t key, void* value) {
|
void Hashtable_put(Hashtable* this, ht_key_t key, void* value) {
|
||||||
|
|
||||||
assert(Hashtable_isConsistent(this));
|
assert(Hashtable_isConsistent(this));
|
||||||
assert(this->size > 0);
|
assert(this->size > 0);
|
||||||
|
@ -211,7 +211,7 @@ void Hashtable_put(Hashtable* this, hkey_t key, void* value) {
|
||||||
assert(this->size > this->items);
|
assert(this->size > this->items);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Hashtable_remove(Hashtable* this, hkey_t key) {
|
void* Hashtable_remove(Hashtable* this, ht_key_t key) {
|
||||||
unsigned int index = key % this->size;
|
unsigned int index = key % this->size;
|
||||||
unsigned int probe = 0;
|
unsigned int probe = 0;
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -266,7 +266,7 @@ void* Hashtable_remove(Hashtable* this, hkey_t key) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Hashtable_get(Hashtable* this, hkey_t key) {
|
void* Hashtable_get(Hashtable* this, ht_key_t key) {
|
||||||
unsigned int index = key % this->size;
|
unsigned int index = key % this->size;
|
||||||
unsigned int probe = 0;
|
unsigned int probe = 0;
|
||||||
void* res = NULL;
|
void* res = NULL;
|
||||||
|
|
12
Hashtable.h
12
Hashtable.h
|
@ -10,12 +10,12 @@ in the source distribution for its full text.
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
|
||||||
typedef unsigned int hkey_t;
|
typedef unsigned int ht_key_t;
|
||||||
|
|
||||||
typedef void(*Hashtable_PairFunction)(hkey_t key, void* value, void* userdata);
|
typedef void(*Hashtable_PairFunction)(ht_key_t key, void* value, void* userdata);
|
||||||
|
|
||||||
typedef struct HashtableItem_ {
|
typedef struct HashtableItem_ {
|
||||||
hkey_t key;
|
ht_key_t key;
|
||||||
unsigned int probe;
|
unsigned int probe;
|
||||||
void* value;
|
void* value;
|
||||||
} HashtableItem;
|
} HashtableItem;
|
||||||
|
@ -41,11 +41,11 @@ void Hashtable_clear(Hashtable* this);
|
||||||
|
|
||||||
void Hashtable_setSize(Hashtable* this, unsigned int size);
|
void Hashtable_setSize(Hashtable* this, unsigned int size);
|
||||||
|
|
||||||
void Hashtable_put(Hashtable* this, hkey_t key, void* value);
|
void Hashtable_put(Hashtable* this, ht_key_t key, void* value);
|
||||||
|
|
||||||
void* Hashtable_remove(Hashtable* this, hkey_t key);
|
void* Hashtable_remove(Hashtable* this, ht_key_t key);
|
||||||
|
|
||||||
void* Hashtable_get(Hashtable* this, hkey_t key);
|
void* Hashtable_get(Hashtable* this, ht_key_t key);
|
||||||
|
|
||||||
void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData);
|
void Hashtable_foreach(Hashtable* this, Hashtable_PairFunction f, void* userData);
|
||||||
|
|
||||||
|
|
|
@ -484,7 +484,7 @@ static inline uint64_t fast_strtoull_hex(char **str, int maxlen) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LinuxProcessList_calcLibSize_helper(ATTR_UNUSED hkey_t key, void* value, void* data) {
|
static void LinuxProcessList_calcLibSize_helper(ATTR_UNUSED ht_key_t key, void* value, void* data) {
|
||||||
if (!data)
|
if (!data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue