Skip to content

Commit

Permalink
kvlist: add _s APIs to pass str length as arg (#36)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: Takahiro Yamashita <[email protected]>
Signed-off-by: Eduardo Silva <[email protected]>
  • Loading branch information
nokute78 authored Feb 25, 2024
1 parent a5b52c3 commit e7b4cbc
Show file tree
Hide file tree
Showing 7 changed files with 1,276 additions and 54 deletions.
47 changes: 47 additions & 0 deletions include/cfl/cfl_kvlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,55 @@ int cfl_kvlist_count(struct cfl_kvlist *list);
struct cfl_variant *cfl_kvlist_fetch(struct cfl_kvlist *list, char *key);
int cfl_kvlist_print(FILE *fp, struct cfl_kvlist *list);

int cfl_kvlist_insert_string_s(struct cfl_kvlist *list,
char *key, size_t key_size,
char *value, size_t value_size);

int cfl_kvlist_insert_bytes_s(struct cfl_kvlist *list,
char *key, size_t key_size,
char *value,
size_t value_length);

int cfl_kvlist_insert_reference_s(struct cfl_kvlist *list,
char *key, size_t key_size,
void *value);

int cfl_kvlist_insert_bool_s(struct cfl_kvlist *list,
char *key, size_t key_size, int value);

int cfl_kvlist_insert_int64_s(struct cfl_kvlist *list,
char *key, size_t key_size,
int64_t value);

int cfl_kvlist_insert_uint64_s(struct cfl_kvlist *list,
char *key, size_t key_size,
uint64_t value);

int cfl_kvlist_insert_double_s(struct cfl_kvlist *list,
char *key, size_t key_size,
double value);

int cfl_kvlist_insert_array_s(struct cfl_kvlist *list,
char *key, size_t key_size,
struct cfl_array *value);

int cfl_kvlist_insert_new_array_s(struct cfl_kvlist *list,
char *key, size_t key_size,
size_t size);

int cfl_kvlist_insert_kvlist_s(struct cfl_kvlist *list,
char *key, size_t key_size,
struct cfl_kvlist *value);

int cfl_kvlist_insert_s(struct cfl_kvlist *list,
char *key, size_t key_size,
struct cfl_variant *value);

struct cfl_variant *cfl_kvlist_fetch_s(struct cfl_kvlist *list, char *key, size_t key_size);

int cfl_kvlist_contains(struct cfl_kvlist *kvlist, char *name);
int cfl_kvlist_remove(struct cfl_kvlist *kvlist, char *name);
void cfl_kvpair_destroy(struct cfl_kvpair *pair);


#endif
3 changes: 2 additions & 1 deletion include/cfl/cfl_variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ struct cfl_variant {
struct cfl_kvlist *as_kvlist;
} data;
};

int cfl_variant_print(FILE *fp, struct cfl_variant *val);
struct cfl_variant *cfl_variant_create_from_string(char *value);
struct cfl_variant *cfl_variant_create_from_string_n(char *value, int len);
struct cfl_variant *cfl_variant_create_from_string_s(char *value, size_t value_length);
struct cfl_variant *cfl_variant_create_from_bytes(char *value, size_t length);
struct cfl_variant *cfl_variant_create_from_bool(int value);
struct cfl_variant *cfl_variant_create_from_int64(int64_t value);
Expand Down
Loading

0 comments on commit e7b4cbc

Please sign in to comment.