#include <ecoli_malloc.h>
#include <ecoli_test.h>
#include <ecoli_log.h>
-#include <ecoli_keyval.h>
+#include <ecoli_dict.h>
#include <ecoli_strvec.h>
EC_LOG_TYPE_REGISTER(strvec);
struct ec_strvec_elt {
unsigned int refcnt;
char *str;
- struct ec_keyval *attrs;
+ struct ec_dict *attrs;
};
struct ec_strvec {
elt->refcnt--;
if (elt->refcnt == 0) {
ec_free(elt->str);
- ec_keyval_free(elt->attrs);
+ ec_dict_free(elt->attrs);
ec_free(elt);
}
}
return strvec->vec[idx]->str;
}
-const struct ec_keyval *ec_strvec_get_attrs(const struct ec_strvec *strvec,
+const struct ec_dict *ec_strvec_get_attrs(const struct ec_strvec *strvec,
size_t idx)
{
if (strvec == NULL || idx >= strvec->len) {
}
int ec_strvec_set_attrs(struct ec_strvec *strvec, size_t idx,
- struct ec_keyval *attrs)
+ struct ec_dict *attrs)
{
struct ec_strvec_elt *elt;
}
if (elt->attrs != NULL)
- ec_keyval_free(elt->attrs);
+ ec_dict_free(elt->attrs);
elt->attrs = attrs;
return 0;
fail:
- ec_keyval_free(attrs);
+ ec_dict_free(attrs);
return -1;
}
{
struct ec_strvec *strvec = NULL;
struct ec_strvec *strvec2 = NULL;
- const struct ec_keyval *const_attrs = NULL;
- struct ec_keyval *attrs = NULL;
+ const struct ec_dict *const_attrs = NULL;
+ struct ec_dict *attrs = NULL;
FILE *f = NULL;
char *buf = NULL;
size_t buflen = 0;
EC_TEST_ERR("cannot create strvec from array\n");
goto fail;
}
- attrs = ec_keyval();
+ attrs = ec_dict();
if (attrs == NULL) {
EC_TEST_ERR("cannot create attrs\n");
goto fail;
}
- if (ec_keyval_set(attrs, "key", "value", NULL) < 0) {
+ if (ec_dict_set(attrs, "key", "value", NULL) < 0) {
EC_TEST_ERR("cannot set attr\n");
goto fail;
}
goto fail;
}
testres |= EC_TEST_CHECK(
- ec_keyval_has_key(const_attrs, "key"), "cannot get attrs key\n");
+ ec_dict_has_key(const_attrs, "key"), "cannot get attrs key\n");
strvec2 = EC_STRVEC("a", "b", "c", "d", "e", "f");
if (strvec2 == NULL) {
fail:
if (f != NULL)
fclose(f);
- ec_keyval_free(attrs);
+ ec_dict_free(attrs);
ec_strvec_free(strvec);
ec_strvec_free(strvec2);
free(buf);