提交 350f9237 编写于 作者: Y YuQing

add function hash_find1 and hash_find2

上级 d27948ed
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
......
......@@ -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)
{
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册