mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[hash] const char *
This commit is contained in:
parent
ce99b8889c
commit
d20216cf53
@ -117,7 +117,7 @@ register_event(char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get_event_id(char *name)
|
get_event_id(const char *name)
|
||||||
{
|
{
|
||||||
struct hash_item *item;
|
struct hash_item *item;
|
||||||
int namelen;
|
int namelen;
|
||||||
|
@ -95,7 +95,7 @@ void unregister_event_hooks(struct event_hook_info *hooks);
|
|||||||
* unregistration), thus it may be cached intermediatelly. */
|
* unregistration), thus it may be cached intermediatelly. */
|
||||||
/* It returns the event id on success or a negative number upon failure
|
/* It returns the event id on success or a negative number upon failure
|
||||||
* (ie. there is no such event). */
|
* (ie. there is no such event). */
|
||||||
int get_event_id(char *name);
|
int get_event_id(const char *name);
|
||||||
|
|
||||||
/* This looks up the events table and returns the name of a given event
|
/* This looks up the events table and returns the name of a given event
|
||||||
* @id. */
|
* @id. */
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#define hash_mask(n) (hash_size(n) - 1)
|
#define hash_mask(n) (hash_size(n) - 1)
|
||||||
#define hash_size(n) (1 << (n))
|
#define hash_size(n) (1 << (n))
|
||||||
|
|
||||||
static hash_value_T strhash(char *k, unsigned int length, hash_value_T initval);
|
static hash_value_T strhash(const char *k, unsigned int length, hash_value_T initval);
|
||||||
|
|
||||||
static inline struct hash *
|
static inline struct hash *
|
||||||
init_hash(unsigned int width, hash_func_T func)
|
init_hash(unsigned int width, hash_func_T func)
|
||||||
@ -82,7 +82,7 @@ free_hash(struct hash **hashp)
|
|||||||
/** @returns hash_item if ok, NULL if error.
|
/** @returns hash_item if ok, NULL if error.
|
||||||
* @relates hash */
|
* @relates hash */
|
||||||
struct hash_item *
|
struct hash_item *
|
||||||
add_hash_item(struct hash *hash, char *key, unsigned int keylen,
|
add_hash_item(struct hash *hash, const char *key, unsigned int keylen,
|
||||||
void *value)
|
void *value)
|
||||||
{
|
{
|
||||||
hash_value_T hashval;
|
hash_value_T hashval;
|
||||||
@ -103,7 +103,7 @@ add_hash_item(struct hash *hash, char *key, unsigned int keylen,
|
|||||||
|
|
||||||
/** @relates hash */
|
/** @relates hash */
|
||||||
struct hash_item *
|
struct hash_item *
|
||||||
get_hash_item(struct hash *hash, char *key, unsigned int keylen)
|
get_hash_item(struct hash *hash, const char *key, unsigned int keylen)
|
||||||
{
|
{
|
||||||
struct list_head *list;
|
struct list_head *list;
|
||||||
struct hash_item *item;
|
struct hash_item *item;
|
||||||
@ -151,7 +151,7 @@ del_hash_item(struct hash *hash, struct hash_item *item)
|
|||||||
* @param length the length of the key
|
* @param length the length of the key
|
||||||
* @param initval the previous hash, or an arbitrary value */
|
* @param initval the previous hash, or an arbitrary value */
|
||||||
static hash_value_T
|
static hash_value_T
|
||||||
strhash(char *k,
|
strhash(const char *k,
|
||||||
unsigned int length,
|
unsigned int length,
|
||||||
hash_value_T initval)
|
hash_value_T initval)
|
||||||
{
|
{
|
||||||
|
@ -11,12 +11,12 @@ extern "C" {
|
|||||||
* happen when this will be of other length, but it should still work ok.
|
* happen when this will be of other length, but it should still work ok.
|
||||||
* --pasky */
|
* --pasky */
|
||||||
typedef unsigned long hash_value_T;
|
typedef unsigned long hash_value_T;
|
||||||
typedef hash_value_T (* hash_func_T)(char *key, unsigned int keylen, hash_value_T magic);
|
typedef hash_value_T (* hash_func_T)(const char *key, unsigned int keylen, hash_value_T magic);
|
||||||
|
|
||||||
struct hash_item {
|
struct hash_item {
|
||||||
LIST_HEAD(struct hash_item);
|
LIST_HEAD(struct hash_item);
|
||||||
|
|
||||||
char *key;
|
const char *key;
|
||||||
unsigned int keylen;
|
unsigned int keylen;
|
||||||
void *value;
|
void *value;
|
||||||
};
|
};
|
||||||
@ -31,8 +31,8 @@ struct hash *init_hash8(void);
|
|||||||
|
|
||||||
void free_hash(struct hash **hashp);
|
void free_hash(struct hash **hashp);
|
||||||
|
|
||||||
struct hash_item *add_hash_item(struct hash *hash, char *key, unsigned int keylen, void *value);
|
struct hash_item *add_hash_item(struct hash *hash, const char *key, unsigned int keylen, void *value);
|
||||||
struct hash_item *get_hash_item(struct hash *hash, char *key, unsigned int keylen);
|
struct hash_item *get_hash_item(struct hash *hash, const char *key, unsigned int keylen);
|
||||||
void del_hash_item(struct hash *hash, struct hash_item *item);
|
void del_hash_item(struct hash *hash, struct hash_item *item);
|
||||||
|
|
||||||
/** @relates hash */
|
/** @relates hash */
|
||||||
|
Loading…
Reference in New Issue
Block a user