Add a version identifier to the header file
Make some of the wrappers inline functions. Should probably do this later for others.
diff --git a/include/cn-cbor/cn-cbor.h b/include/cn-cbor/cn-cbor.h
index 6d908eb..7b7a2db 100644
--- a/include/cn-cbor/cn-cbor.h
+++ b/include/cn-cbor/cn-cbor.h
@@ -8,6 +8,8 @@
#ifndef CN_CBOR_H
#define CN_CBOR_H
+#define CN_CBOR_VERSION 0x010100
+
#ifdef __MBED__
#include <stddef.h>
#endif
@@ -391,7 +393,7 @@
* @return The created object, or NULL on error
*/
MYLIB_EXPORT
-cn_cbor* cn_cbor_string_create(const char* data CBOR_CONTEXT, cn_cbor_errback* errp);
+cn_cbor* cn_cbor_string_create(const char* data, CBOR_CONTEXT_COMMA cn_cbor_errback* errp);
/**
* Create a CBOR UTF-8 string. The data is not checked for UTF-8 correctness.
@@ -444,7 +446,7 @@
#endif /* CBOR_NO_FLOAT */
/**
- * Create a CBOR simple boolean.
+ * Create a CBOR simple value.
*
* @note: Do NOT use this function with untrusted data. It calls strlen, and
* relies on proper NULL-termination.
@@ -454,10 +456,23 @@
* @param[out] errp Error, if NULL is returned
* @return The created object, or NULL on error
*/
-MYLIB_EXPORT
-cn_cbor* cn_cbor_simple_create(int simpleValue CBOR_CONTEXT, cn_cbor_errback* errp);
+cn_cbor* cn_cbor_simple_create(int simpleValue, CBOR_CONTEXT_COMMA cn_cbor_errback* errp);
-#define cn_cbor_null_create(context, error) cn_cbor_simple_create(22, context, error)
+/**
+ * Create a CBOR NULL
+ *
+ * @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
+ */
+static inline cn_cbor* cn_cbor_null_create(CBOR_CONTEXT_COMMA cn_cbor_errback* errp)
+{
+ return cn_cbor_simple_create(22,
+#ifdef USE_CBOR_CONTEXT
+ context,
+#endif
+ errp);
+}
/**
* Tag a CBOR object
@@ -484,8 +499,15 @@
* @param[out] errp Error, if NULL is returned
* @return The created object, or NULL on error
*/
-MYLIB_EXPORT
-cn_cbor* cn_cbor_bool_create(bool value CBOR_CONTEXT, cn_cbor_errback* errp);
+
+static inline cn_cbor* cn_cbor_bool_create(bool value CBOR_CONTEXT, cn_cbor_errback* errp)
+{
+ return cn_cbor_simple_create(value ? 21 : 20,
+#ifdef USE_CBOR_CONTEXT
+ context,
+#endif
+ errp);
+}
/**
* Create a chunked text or byte string.
diff --git a/src/cn-create.c b/src/cn-create.c
index 038fc95..85c58d7 100644
--- a/src/cn-create.c
+++ b/src/cn-create.c
@@ -25,16 +25,6 @@
}
MYLIB_EXPORT
-cn_cbor* cn_cbor_bool_create(bool value CBOR_CONTEXT, cn_cbor_errback* errp)
-{
- cn_cbor* ret;
- INIT_CB(ret);
-
- ret->type = CN_CBOR_FALSE + (value != 0);
- return ret;
-}
-
-MYLIB_EXPORT
cn_cbor* cn_cbor_simple_create(int simpleValue, CBOR_CONTEXT_COMMA cn_cbor_errback* errp)
{
if (24 <= simpleValue && simpleValue <= 31) {