mirror of
https://github.com/samsonjs/lake.git
synced 2026-03-25 08:55:49 +00:00
Fix a warning and use a better hash name
This commit is contained in:
parent
001478f7e8
commit
b24d30af75
3 changed files with 14 additions and 14 deletions
12
src/hash.c
12
src/hash.c
|
|
@ -12,21 +12,21 @@
|
||||||
|
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
|
||||||
void lake_hash_put(khash_t(value) * h, char *key, void *val)
|
void lake_hash_put(khash_t(LakeVal) * h, char *key, void *val)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
khiter_t k = kh_put(value, h, key, &ret);
|
khiter_t k = kh_put(LakeVal, h, key, &ret);
|
||||||
kh_value(h, k) = val;
|
kh_value(h, k) = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *lake_hash_get(khash_t(value) * h, char *key)
|
void *lake_hash_get(khash_t(LakeVal) * h, char *key)
|
||||||
{
|
{
|
||||||
khiter_t k = kh_get(value, h, key);
|
khiter_t k = kh_get(LakeVal, h, key);
|
||||||
return k == kh_end(h) ? NULL : kh_value(h, k);
|
return k == kh_end(h) ? NULL : kh_value(h, k);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lake_hash_has(khash_t(value) * h, char *key)
|
bool lake_hash_has(khash_t(LakeVal) * h, char *key)
|
||||||
{
|
{
|
||||||
khiter_t k = kh_get(value, h, key);
|
khiter_t k = kh_get(LakeVal, h, key);
|
||||||
return kh_exist(h, k);
|
return kh_exist(h, k);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
src/hash.h
14
src/hash.h
|
|
@ -16,15 +16,15 @@
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "khash.h"
|
#include "khash.h"
|
||||||
|
|
||||||
KHASH_MAP_INIT_STR(value, void *);
|
KHASH_MAP_INIT_STR(LakeVal, void *);
|
||||||
|
|
||||||
typedef khash_t(value) lake_hash_t;
|
typedef khash_t(LakeVal) lake_hash_t;
|
||||||
|
|
||||||
#define lake_hash_make() kh_init(value)
|
#define lake_hash_make() kh_init(LakeVal)
|
||||||
#define lake_hash_free(h) kh_destroy(value, h)
|
#define lake_hash_free(h) kh_destroy(LakeVal, h)
|
||||||
|
|
||||||
bool lake_hash_has(khash_t(value) * h, char *key);
|
bool lake_hash_has(khash_t(LakeVal) * h, char *key);
|
||||||
void lake_hash_put(khash_t(value) * h, char *key, void *val);
|
void lake_hash_put(khash_t(LakeVal) * h, char *key, void *val);
|
||||||
void *lake_hash_get(khash_t(value) * h, char *key);
|
void *lake_hash_get(khash_t(LakeVal) * h, char *key);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ static char *test_int_repr(void)
|
||||||
i = int_from_c(2147483647);
|
i = int_from_c(2147483647);
|
||||||
lt_assert("int_repr is wrong", strcmp(int_repr(i), "2147483647") == 0);
|
lt_assert("int_repr is wrong", strcmp(int_repr(i), "2147483647") == 0);
|
||||||
|
|
||||||
i = int_from_c(2147483648);
|
i = int_from_c((unsigned int)2147483648);
|
||||||
lt_assert("int_repr is wrong", strcmp(int_repr(i), "-2147483648") == 0);
|
lt_assert("int_repr is wrong", strcmp(int_repr(i), "-2147483648") == 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue