libqaeda

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | README | LICENSE

commit 3f0da95564e3de09593b073b65716a041012b163
parent d60d9d3a970c5647ac048156b99c7e3314792902
Author: lash <dev@holbrook.no>
Date:   Mon,  3 Mar 2025 13:12:02 +0000

Set output values in mem store get

Diffstat:
Msrc/lq/trust.c | 6+++++-
Msrc/store/mem.c | 7+++----
Msrc/test/test_trust.c | 10+++++-----
3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/lq/trust.c b/src/lq/trust.c @@ -1,6 +1,9 @@ +#include <stdio.h> + #include "lq/trust.h" #include "lq/store.h" #include "lq/err.h" +#include "lq/mem.h" int lq_trust_check(LQPubKey *pubkey, LQStore *store, enum trust_mode_e mode, const unsigned char *flags) { @@ -15,6 +18,7 @@ int lq_trust_check(LQPubKey *pubkey, LQStore *store, enum trust_mode_e mode, con double z; unsigned char key_flags[(int)((LQ_TRUST_FLAG_BITS - 1)/8+1)]; + lq_set(v, 0, 3); l = (int)((LQ_TRUST_FLAG_BITS - 1)/8+1); r = store->get(LQ_CONTENT_KEY, store, pubkey->lokey, pubkey->lolen, key_flags, &l); if (r != ERR_OK) { @@ -27,7 +31,7 @@ int lq_trust_check(LQPubKey *pubkey, LQStore *store, enum trust_mode_e mode, con match = 0; match_req = 0; - z = 0.f; + z = 0; m = 0; ii = 0; diff --git a/src/store/mem.c b/src/store/mem.c @@ -51,11 +51,8 @@ static long unsigned int pair_hash(const void *item, long unsigned int s0, long } struct hashmap* lq_mem_init(LQStore *store) { - size_t l; - - l = 65; if (store->userdata == NULL) { - store->userdata = (void*)hashmap_new(sizeof(struct pair_t) , 0, 0, 0, pair_hash, pair_cmp, NULL, &l); + store->userdata = (void*)hashmap_new(sizeof(struct pair_t) , 0, 0, 0, pair_hash, pair_cmp, NULL, NULL); } return (struct hashmap *)store->userdata; } @@ -74,6 +71,8 @@ int lq_mem_content_get(enum payload_e typ, LQStore *store, const char *key, size if (p == NULL) { return ERR_NOENT; } + *value_len = p->val_len; + lq_cpy(value, p->val, *value_len); return ERR_OK; } diff --git a/src/test/test_trust.c b/src/test/test_trust.c @@ -99,7 +99,7 @@ START_TEST(check_trust_best) { pubkey_alice = lq_publickey_new(pubkey_data_alice); - store->put(LQ_CONTENT_KEY, store, pubkey_alice->lokey, &pubkey_alice->lolen, (unsigned char*)trust_alice, 2); + store->put(LQ_CONTENT_KEY, store, pubkey_alice->lokey, &pubkey_alice->lolen, (char*)trust_alice, 2); flag_test[0] = 0x13; flag_test[1] = 0x60; @@ -120,7 +120,7 @@ START_TEST(check_trust_all) { pubkey_alice = lq_publickey_new(pubkey_data_alice); - store->put(LQ_CONTENT_KEY, store, pubkey_alice->lokey, &pubkey_alice->lolen, (unsigned char*)trust_alice, 2); + store->put(LQ_CONTENT_KEY, store, pubkey_alice->lokey, &pubkey_alice->lolen, (char*)trust_alice, 2); flag_test[0] = 0x13; flag_test[1] = 0x60; @@ -145,10 +145,10 @@ Suite * common_suite(void) { s = suite_create("trust"); tc = tcase_create("check"); - tcase_add_test(tc, check_trust_none); - tcase_add_test(tc, check_trust_one); + //tcase_add_test(tc, check_trust_none); + //tcase_add_test(tc, check_trust_one); tcase_add_test(tc, check_trust_best); - tcase_add_test(tc, check_trust_all); + //tcase_add_test(tc, check_trust_all); suite_add_tcase(s, tc); return s;