Skip to content
This repository was archived by the owner on Apr 9, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/cn-cbor/cn-cbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,18 @@ ssize_t cn_cbor_encoder_write(uint8_t *buf,
size_t buf_size,
const cn_cbor *cb);

/**
* Create a CBOR object.
*
* @param[in] type the type of the object
* @param[in] CBOR_CONTEXT Allocation context (only if USE_CBOR_CONTEXT is defined)
* @param[out] errp Error, if NULL is returned
* @return The created object, or NULL on error
*/
cn_cbor* cn_cbor_create(cn_cbor_type type
CBOR_CONTEXT,
cn_cbor_errback *errp);

/**
* Create a CBOR map.
*
Expand Down
12 changes: 12 additions & 0 deletions src/cn-create.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ extern "C" {
(v) = CN_CALLOC_CONTEXT(); \
if (!(v)) { if (errp) {errp->err = CN_CBOR_ERR_OUT_OF_MEMORY;} return NULL; }

cn_cbor* cn_cbor_create(cn_cbor_type type
CBOR_CONTEXT,
cn_cbor_errback *errp)
{
cn_cbor* ret;
INIT_CB(ret);

ret->type = type;

return ret;
}

cn_cbor* cn_cbor_map_create(CBOR_CONTEXT_COMMA cn_cbor_errback *errp)
{
cn_cbor* ret;
Expand Down