From 365470d625ae9109329a311d582ef1f6cb67b55e Mon Sep 17 00:00:00 2001 From: Takahiro Yamashita Date: Sun, 21 May 2023 07:22:42 +0900 Subject: [PATCH] kvlist: support uint64_t Signed-off-by: Takahiro Yamashita --- include/cfl/cfl_kvlist.h | 3 +++ src/cfl_kvlist.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/cfl/cfl_kvlist.h b/include/cfl/cfl_kvlist.h index 5f920e5..d766e96 100644 --- a/include/cfl/cfl_kvlist.h +++ b/include/cfl/cfl_kvlist.h @@ -54,6 +54,9 @@ int cfl_kvlist_insert_bool(struct cfl_kvlist *list, int cfl_kvlist_insert_int64(struct cfl_kvlist *list, char *key, int64_t value); +int cfl_kvlist_insert_uint64(struct cfl_kvlist *list, + char *key, uint64_t value); + int cfl_kvlist_insert_double(struct cfl_kvlist *list, char *key, double value); diff --git a/src/cfl_kvlist.c b/src/cfl_kvlist.c index 56139b8..bdfc9f0 100644 --- a/src/cfl_kvlist.c +++ b/src/cfl_kvlist.c @@ -212,6 +212,29 @@ int cfl_kvlist_insert_int64(struct cfl_kvlist *list, return 0; } +int cfl_kvlist_insert_uint64(struct cfl_kvlist *list, + char *key, uint64_t value) +{ + struct cfl_variant *value_instance; + int result; + + value_instance = cfl_variant_create_from_uint64(value); + + if (value_instance == NULL) { + return -1; + } + + result = cfl_kvlist_insert(list, key, value_instance); + + if (result) { + cfl_variant_destroy(value_instance); + + return -2; + } + + return 0; +} + int cfl_kvlist_insert_double(struct cfl_kvlist *list, char *key, double value) {