add function hash_find1 and hash_find2
parent
d27948ed9c
commit
350f923710
3
HISTORY
3
HISTORY
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
Version 1.40 2018-10-11
|
||||
Version 1.40 2018-10-26
|
||||
* add function conn_pool_parse_server_info and conn_pool_load_server_info
|
||||
* support directive: #@add_annotation, for example:
|
||||
#@add_annotation CONFIG_GET /usr/lib/libshmcache.so /etc/libshmcache.conf
|
||||
|
|
@ -8,6 +8,7 @@ Version 1.40 2018-10-11
|
|||
* add function fc_strdup
|
||||
* add function fc_memmem
|
||||
* add function format_http_date
|
||||
* add function hash_find1 and hash_find2
|
||||
|
||||
Version 1.39 2018-07-31
|
||||
* add #@function REPLACE_VARS
|
||||
|
|
|
|||
18
src/hash.c
18
src/hash.c
|
|
@ -568,6 +568,24 @@ void *hash_find(HashArray *pHash, const void *key, const int key_len)
|
|||
}
|
||||
}
|
||||
|
||||
int hash_find2(HashArray *pHash, const string_t *key, string_t *value)
|
||||
{
|
||||
HashData *hdata;
|
||||
if ((hdata=hash_find1_ex(pHash, key)) == NULL)
|
||||
{
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
value->str = hdata->value;
|
||||
value->len = hdata->value_len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
HashData *hash_find1_ex(HashArray *pHash, const string_t *key)
|
||||
{
|
||||
return hash_find_ex(pHash, key->str, key->len);
|
||||
}
|
||||
|
||||
int hash_get(HashArray *pHash, const void *key, const int key_len,
|
||||
void *value, int *value_len)
|
||||
{
|
||||
|
|
|
|||
30
src/hash.h
30
src/hash.h
|
|
@ -198,6 +198,36 @@ void *hash_find(HashArray *pHash, const void *key, const int key_len);
|
|||
*/
|
||||
HashData *hash_find_ex(HashArray *pHash, const void *key, const int key_len);
|
||||
|
||||
/**
|
||||
* hash find key
|
||||
* parameters:
|
||||
* pHash: the hash table
|
||||
* key: the key to find
|
||||
* return user data, return NULL when the key not exist
|
||||
*/
|
||||
static inline void *hash_find1(HashArray *pHash, const string_t *key)
|
||||
{
|
||||
return hash_find(pHash, key->str, key->len);
|
||||
}
|
||||
|
||||
/**
|
||||
* hash get the value of the key
|
||||
* parameters:
|
||||
* pHash: the hash table
|
||||
* key: the key to find
|
||||
* value: store the value
|
||||
* return 0 for success, != 0 fail (errno)
|
||||
*/
|
||||
int hash_find2(HashArray *pHash, const string_t *key, string_t *value);
|
||||
|
||||
/**
|
||||
* hash find key
|
||||
* parameters:
|
||||
* pHash: the hash table
|
||||
* key: the key to find
|
||||
* return hash data, return NULL when the key not exist
|
||||
*/
|
||||
HashData *hash_find1_ex(HashArray *pHash, const string_t *key);
|
||||
|
||||
/**
|
||||
* hash get the value of the key
|
||||
|
|
|
|||
Loading…
Reference in New Issue