grammar, formatting
diff --git a/inc/qcbor/qcbor_common.h b/inc/qcbor/qcbor_common.h
index 9cc08b1..1fd5bc8 100644
--- a/inc/qcbor/qcbor_common.h
+++ b/inc/qcbor/qcbor_common.h
@@ -1,6 +1,6 @@
/*==============================================================================
Copyright (c) 2016-2018, The Linux Foundation.
- Copyright (c) 2018-2022, Laurence Lundblade.
+ Copyright (c) 2018-2023, Laurence Lundblade.
Copyright (c) 2021, Arm Limited.
All rights reserved.
@@ -78,25 +78,25 @@
-/* Standard CBOR Major type for positive integers of various lengths */
+/* Standard CBOR Major type for positive integers of various lengths. */
#define CBOR_MAJOR_TYPE_POSITIVE_INT 0
-/* Standard CBOR Major type for negative integer of various lengths */
+/* Standard CBOR Major type for negative integer of various lengths. */
#define CBOR_MAJOR_TYPE_NEGATIVE_INT 1
/* Standard CBOR Major type for an array of arbitrary 8-bit bytes. */
#define CBOR_MAJOR_TYPE_BYTE_STRING 2
/* Standard CBOR Major type for a UTF-8 string. Note this is true 8-bit UTF8
- with no encoding and no NULL termination */
+ * with no encoding and no NULL termination. */
#define CBOR_MAJOR_TYPE_TEXT_STRING 3
-/* Standard CBOR Major type for an ordered array of other CBOR data items */
+/* Standard CBOR Major type for an ordered array of other CBOR data items. */
#define CBOR_MAJOR_TYPE_ARRAY 4
/* Standard CBOR Major type for CBOR MAP. Maps an array of pairs. The
- first item in the pair is the "label" (key, name or identfier) and the second
- item is the value. */
+ * first item in the pair is the "label" (key, name or identfier) and the second
+ * item is the value. */
#define CBOR_MAJOR_TYPE_MAP 5
/* Standard CBOR major type for a tag number. This creates a CBOR "tag" that
@@ -109,16 +109,16 @@
#define CBOR_MAJOR_TYPE_TAG 6
#define CBOR_MAJOR_TYPE_OPTIONAL 6
-/* Standard CBOR extra simple types like floats and the values true and false */
+/* Standard CBOR simple types like float, the values true, false, null... */
#define CBOR_MAJOR_TYPE_SIMPLE 7
/*
- Tags that are used with CBOR_MAJOR_TYPE_OPTIONAL. These
- are types defined in RFC 8949 and some additional ones
- in the IANA CBOR tags registry.
+ * Tags that are used with CBOR_MAJOR_TYPE_OPTIONAL. These
+ * are types defined in RFC 8949 and some additional ones
+ * in the IANA CBOR tags registry.
*/
/** See QCBOREncode_AddDateString(). */
#define CBOR_TAG_DATE_STRING 0
@@ -239,7 +239,7 @@
/**
* Error codes returned by QCBOR Encoder and Decoder.
*
- * The errors are grouped to keep the code size of
+ * They are grouped to keep the code size of
* QCBORDecode_IsNotWellFormedError() and
* QCBORDecode_IsUnrecoverableError() minimal.
*
@@ -253,7 +253,7 @@
* added for new QCBOR features.
*/
typedef enum {
- /** The encode or decode completely correctly. */
+ /** The encode or decode completed correctly. */
QCBOR_SUCCESS = 0,
/** The buffer provided for the encoded output when doing encoding
@@ -265,18 +265,18 @@
QCBOR_ERR_ENCODE_UNSUPPORTED = 2,
/** During encoding, the length of the encoded CBOR exceeded
- * QCBOR_MAX_ARRAY_OFFSET, which is slightly less than
+ * @ref QCBOR_MAX_ARRAY_OFFSET, which is slightly less than
* @c UINT32_MAX. */
QCBOR_ERR_BUFFER_TOO_LARGE = 3,
/** During encoding, the array or map nesting was deeper than this
* implementation can handle. Note that in the interest of code
- * size and memory use, this implementation has a hard limit on
- * array nesting. The limit is defined as the constant @ref
- * QCBOR_MAX_ARRAY_NESTING. */
+ * size and memory use, QCBOR has a hard limit on array
+ * nesting. The limit is defined as the constant
+ * @ref QCBOR_MAX_ARRAY_NESTING. */
QCBOR_ERR_ARRAY_NESTING_TOO_DEEP = 4,
- /** During encoding, @c QCBOREncode_CloseXxx() called with a
+ /** During encoding, @c QCBOREncode_CloseXxx() called for a
* different type than is currently open. */
QCBOR_ERR_CLOSE_MISMATCH = 5,
@@ -289,13 +289,13 @@
* encoder. */
QCBOR_ERR_TOO_MANY_CLOSES = 7,
- /** During encoding the number of array or map opens was not
- matched by the number of closes. Also occurs with opened
- byte strings that are not closed. */
+ /** During encoding, the number of array or map opens was not
+ * matched by the number of closes. Also occurs with opened byte
+ * strings that are not closed. */
QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN = 8,
- /** During encode, opening a byte string while a byte string is open
- is not allowed. . */
+ /** During encoding, opening a byte string while a byte string is
+ * open is not allowed. */
QCBOR_ERR_OPEN_BYTE_STRING = 9,
/** Trying to cancel a byte string wrapping after items have been
@@ -305,8 +305,8 @@
#define QCBOR_START_OF_NOT_WELL_FORMED_ERRORS 20
/** During decoding, the CBOR is not well-formed because a simple
- * value between 0 and 31 is encoded in a two-byte integer rather
- * than one. */
+ * value between 0 and 31 is encoded in a two-byte integer rather
+ * than one. */
QCBOR_ERR_BAD_TYPE_7 = 20,
/** During decoding, returned by QCBORDecode_Finish() if all the
@@ -342,9 +342,9 @@
/** During decoding, hit the end of the given data to decode. For
* example, a byte string of 100 bytes was expected, but the end
* of the input was hit before finding those 100 bytes. Corrupted
- * CBOR input will often result in this error. See also @ref
- * QCBOR_ERR_NO_MORE_ITEMS. The CBOR is not well-formed. This
- * error makes no further decoding possible. */
+ * CBOR input will often result in this error. See also
+ * @ref QCBOR_ERR_NO_MORE_ITEMS. The CBOR is not well-formed.
+ * This error makes no further decoding possible. */
QCBOR_ERR_HIT_END = 31,
/** During decoding, a break occurred outside an indefinite-length
@@ -361,10 +361,10 @@
/** During decoding, the array or map nesting was deeper than this
* implementation can handle. Note that in the interest of code
- * size and memory use, this implementation has a hard limit on
- * array nesting. The limit is defined as the constant @ref
- * QCBOR_MAX_ARRAY_NESTING. This error makes no further decoding
- * possible. */
+ * size and memory use, QCBOR has a hard limit on array
+ * nesting. The limit is defined as the constant
+ * @ref QCBOR_MAX_ARRAY_NESTING. This error makes no further
+ * decoding possible. */
QCBOR_ERR_ARRAY_DECODE_NESTING_TOO_DEEP = 41,
/** During decoding, the array or map had too many items in it.
@@ -399,17 +399,17 @@
/** During decoding, the type of the label for a map entry is not
* one that can be handled in the current decoding mode. Typically
- * this is because a label is not an intger or a string. This is
- * an implemation limit. */
+ * this is because a label is not an integer or a string. This is
+ * an implementation limit. */
QCBOR_ERR_MAP_LABEL_TYPE = 47,
/** When the built-in tag decoding encounters an unexpected type,
* this error is returned. This error is unrecoverable because the
* built-in tag decoding doesn't try to consume the unexpected
* type. In previous versions of QCBOR this was considered a
- * recoverable error hence QCBOR_ERR_BAD_TAG_CONTENT. Going back
- * further, RFC 7049 use the name "optional tags". That name is no
- * longer used because "optional" was causing confusion. See
+ * recoverable error hence @ref QCBOR_ERR_BAD_TAG_CONTENT. Going
+ * back further, RFC 7049 use the name "optional tags". That name
+ * is no longer used because "optional" was causing confusion. See
* also @ref QCBOR_ERR_RECOVERABLE_BAD_TAG_CONTENT. */
QCBOR_ERR_UNRECOVERABLE_TAG_CONTENT = 48,
QCBOR_ERR_BAD_TAG_CONTENT = 48,
@@ -419,34 +419,34 @@
* indefinite length string in the input CBOR. */
QCBOR_ERR_INDEF_LEN_STRINGS_DISABLED = 49,
- /** Indefinite length arrays and maps handling are disabled and there is an
- * indefinite length map or array in the input CBOR. */
+ /** Indefinite length arrays and maps handling are disabled and
+ * there is an indefinite length map or array in the input
+ * CBOR. */
QCBOR_ERR_INDEF_LEN_ARRAYS_DISABLED = 50,
/** All decoding of tags (major type 6) has been disabled and a tag
- occurred in the decode input. */
+ * occurred in the decode input. */
QCBOR_ERR_TAGS_DISABLED = 51,
#define QCBOR_END_OF_UNRECOVERABLE_DECODE_ERRORS 59
- /** More than @ref QCBOR_MAX_TAGS_PER_ITEM tags encounterd for a
+ /** More than @ref QCBOR_MAX_TAGS_PER_ITEM tags encountered for a
* CBOR ITEM. @ref QCBOR_MAX_TAGS_PER_ITEM is a limit of this
* implementation. During decoding, too many tags in the
- * caller-configured tag list, or not enough space in @ref
- * QCBORTagListOut. This error makes no further decoding
+ * caller-configured tag list, or not enough space in
+ * @ref QCBORTagListOut. This error makes no further decoding
* possible. */
QCBOR_ERR_TOO_MANY_TAGS = 60,
- /** When decodeing for a specific type, the type was not was
- * expected. */
+ /** When decoding for a specific type, the type was not expected. */
QCBOR_ERR_UNEXPECTED_TYPE = 61,
- /** Duplicate label in map detected. */
+ /** Duplicate label detected in a map. */
QCBOR_ERR_DUPLICATE_LABEL = 62,
/** During decoding, the buffer given to QCBORDecode_SetMemPool()
* is either too small, smaller than
- * QCBOR_DECODE_MIN_MEM_POOL_SIZE or too large, larger than
+ * @ref QCBOR_DECODE_MIN_MEM_POOL_SIZE or too large, larger than
* UINT32_MAX. */
QCBOR_ERR_MEM_POOL_SIZE = 63,
@@ -466,12 +466,12 @@
/** All well-formed data items have been consumed and there are no
* more. If parsing a CBOR stream this indicates the non-error end
- * of the stream. If not parsing a CBOR stream / sequence, this
+ * of the stream. If not parsing a CBOR stream/sequence, this
* probably indicates that some data items expected are not
* present. See also @ref QCBOR_ERR_HIT_END. */
QCBOR_ERR_NO_MORE_ITEMS = 67,
- /** When finding an item by lablel, an item with the requested label
+ /** When finding an item by label, an item with the requested label
* was not found. */
QCBOR_ERR_LABEL_NOT_FOUND = 68,
@@ -479,8 +479,8 @@
* negative int64_t can't be converted to a uint64_t */
QCBOR_ERR_NUMBER_SIGN_CONVERSION = 69,
- /** When converting a decoded number, the value is too large or to
- * small for the conversion target */
+ /** When converting a decoded number, the value is too large or too
+ * small for the conversion target. */
QCBOR_ERR_CONVERSION_UNDER_OVER_FLOW = 70,
/** Trying to get an item by label when a map has not been
@@ -488,12 +488,12 @@
QCBOR_ERR_MAP_NOT_ENTERED = 71,
/** A callback indicates processing should not continue for some
- * non-CBOR reason */
+ * non-CBOR reason. */
QCBOR_ERR_CALLBACK_FAIL = 72,
/** This error code is deprecated. Instead,
- * \ref QCBOR_ERR_HALF_PRECISION_DISABLED,
- * \ref QCBOR_ERR_HW_FLOAT_DISABLED or \ref QCBOR_ERR_ALL_FLOAT_DISABLED
+ * @ref QCBOR_ERR_HALF_PRECISION_DISABLED,
+ * @ref QCBOR_ERR_HW_FLOAT_DISABLED or @ref QCBOR_ERR_ALL_FLOAT_DISABLED
* is returned depending on the specific floating-point functionality
* that is disabled and the type of floating-point input. */
QCBOR_ERR_FLOAT_DATE_DISABLED = 73,
@@ -512,15 +512,15 @@
* attempted. */
QCBOR_ERR_FLOAT_EXCEPTION = 76,
- /** Floating point support is completely turned off, encoding/decoding
- * floating point numbers is not possible. */
+ /** Floating point support is completely turned off,
+ * encoding/decoding floating point numbers is not possible. */
QCBOR_ERR_ALL_FLOAT_DISABLED = 77,
/** Like @ref QCBOR_ERR_UNRECOVERABLE_TAG_CONTENT, but recoverable.
* If an implementation decodes a tag and can and does consume the
* whole tag contents when it is not the correct tag content, this
- * error can be returned. None of the built-in tag decoders do
- * this (to save object code). */
+ * error can be returned. None of the built-in tag decoders do this
+ * (to save object code). */
QCBOR_ERR_RECOVERABLE_BAD_TAG_CONTENT = 78
/* This is stored in uint8_t; never add values > 255 */
@@ -532,7 +532,7 @@
*
* @param[in] err The error code.
*
- * @return NULL-terimated string describing error or "Unidentified
+ * @return NULL-terminated string describing error or "Unidentified
* error" if the error is not known.
*/
const char *qcbor_err_to_str(QCBORError err);
@@ -543,10 +543,10 @@
/**
* The maximum nesting of arrays and maps when encoding or
* decoding. The error @ref QCBOR_ERR_ARRAY_NESTING_TOO_DEEP will be
- * returned on encoding or QCBOR_ERR_ARRAY_DECODE_NESTING_TOO_DEEP on
- * decoding if it is exceeded.
+ * returned on encoding or @ref QCBOR_ERR_ARRAY_DECODE_NESTING_TOO_DEEP on
+ * decoding if it is exceeded. Do not increase this over 255.
*/
-#define QCBOR_MAX_ARRAY_NESTING QCBOR_MAX_ARRAY_NESTING1
+#define QCBOR_MAX_ARRAY_NESTING 15
/**
@@ -560,16 +560,6 @@
*/
-/**
- * This is deprecated. See QCBORDecode_GetNthTag() and
- * QCBORDecode_GetNthTagOfLast() for tag handling.
- *
- * The maximum number of tags that can be in @ref QCBORTagListIn and
- * passed to QCBORDecode_SetCallerConfiguredTagList()
- */
-#define QCBOR_MAX_CUSTOM_TAGS 16
-
-
#ifdef __cplusplus
}
#endif
diff --git a/inc/qcbor/qcbor_private.h b/inc/qcbor/qcbor_private.h
index 17daccd..725f27b 100644
--- a/inc/qcbor/qcbor_private.h
+++ b/inc/qcbor/qcbor_private.h
@@ -1,6 +1,6 @@
/*==============================================================================
Copyright (c) 2016-2018, The Linux Foundation.
- Copyright (c) 2018-2021, Laurence Lundblade.
+ Copyright (c) 2018-2023, Laurence Lundblade.
Copyright (c) 2021, Arm Limited.
All rights reserved.
@@ -38,6 +38,7 @@
#include <stdint.h>
#include "UsefulBuf.h"
+#include "qcbor/qcbor_common.h"
#ifdef __cplusplus
@@ -72,8 +73,8 @@
/*
- These are special values for the AdditionalInfo bits that are part of
- the first byte. Mostly they encode the length of the data item.
+ * These are special values for the AdditionalInfo bits that are part of
+ * the first byte. Mostly they encode the length of the data item.
*/
#define LEN_IS_ONE_BYTE 24
#define LEN_IS_TWO_BYTES 25
@@ -86,16 +87,14 @@
/*
- 24 is a special number for CBOR. Integers and lengths
- less than it are encoded in the same byte as the major type.
+ * 24 is a special number for CBOR. Integers and lengths
+ * less than it are encoded in the same byte as the major type.
*/
#define CBOR_TWENTY_FOUR 24
-
-
/*
- Values for the 5 bits for items of major type 7
+ * Values for the 5 bits for items of major type 7
*/
#define CBOR_SIMPLEV_FALSE 20
#define CBOR_SIMPLEV_TRUE 21
@@ -111,56 +110,49 @@
-/*
- The maxium nesting of arrays and maps when encoding or decoding.
- (Further down in the file there is a definition that refers to this
- that is public. This is done this way so there can be a nice
- separation of public and private parts in this file.
-*/
-#define QCBOR_MAX_ARRAY_NESTING1 15 // Do not increase this over 255
-
-
/* The largest offset to the start of an array or map. It is slightly
- less than UINT32_MAX so the error condition can be tested on 32-bit machines.
- UINT32_MAX comes from uStart in QCBORTrackNesting being a uin32_t.
-
- This will cause trouble on a machine where size_t is less than 32-bits.
+ * less than UINT32_MAX so the error condition can be tested on 32-bit
+ * machines. UINT32_MAX comes from uStart in QCBORTrackNesting being
+ * a uin32_t.
+ *
+ * This will cause trouble on a machine where size_t is less than 32-bits.
*/
#define QCBOR_MAX_ARRAY_OFFSET (UINT32_MAX - 100)
/* The number of tags that are 16-bit or larger that can be handled
- in a decode.
+ * in a decode.
*/
#define QCBOR_NUM_MAPPED_TAGS 4
/* The number of tags (of any size) recorded for an individual item. */
#define QCBOR_MAX_TAGS_PER_ITEM1 4
+
/*
- Convenience macro for selecting the proper return value in case floating
- point feature(s) are disabled.
-
- The macros:
-
- FLOAT_ERR_CODE_NO_FLOAT(x) Can be used when disabled floating point should
- result error, and all other cases should return
- 'x'.
-
- The below macros always return QCBOR_ERR_ALL_FLOAT_DISABLED when all floating
- point is disabled.
-
- FLOAT_ERR_CODE_NO_HALF_PREC(x) Can be used when disabled preferred float
- results in error, and all other cases should
- return 'x'.
- FLOAT_ERR_CODE_NO_FLOAT_HW(x) Can be used when disabled hardware floating
- point results in error, and all other cases
- should return 'x'.
- FLOAT_ERR_CODE_NO_HALF_PREC_NO_FLOAT_HW(x) Can be used when either disabled
- preferred float or disabling
- hardware floating point results in
- error, and all other cases should
- return 'x'.
+ * Convenience macro for selecting the proper return value in case floating
+ * point feature(s) are disabled.
+ *
+ * The macros:
+ *
+ * FLOAT_ERR_CODE_NO_FLOAT(x) Can be used when disabled floating point should
+ * result error, and all other cases should return
+ * 'x'.
+ *
+ * The below macros always return QCBOR_ERR_ALL_FLOAT_DISABLED when all
+ * floating point is disabled.
+ *
+ * FLOAT_ERR_CODE_NO_HALF_PREC(x) Can be used when disabled preferred float
+ * results in error, and all other cases should
+ * return 'x'.
+ * FLOAT_ERR_CODE_NO_FLOAT_HW(x) Can be used when disabled hardware floating
+ * point results in error, and all other cases
+ * should return 'x'.
+ * FLOAT_ERR_CODE_NO_HALF_PREC_NO_FLOAT_HW(x) Can be used when either disabled
+ * preferred float or disabling
+ * hardware floating point results in
+ * error, and all other cases should
+ * return 'x'.
*/
#ifdef USEFULBUF_DISABLE_ALL_FLOAT
#define FLOAT_ERR_CODE_NO_FLOAT(x) QCBOR_ERR_ALL_FLOAT_DISABLED
@@ -189,19 +181,20 @@
/*
- PRIVATE DATA STRUCTURE
-
- Holds the data for tracking array and map nesting during encoding. Pairs up
- with the Nesting_xxx functions to make an "object" to handle nesting encoding.
-
- uStart is a uint32_t instead of a size_t to keep the size of this
- struct down so it can be on the stack without any concern. It would be about
- double if size_t was used instead.
-
- Size approximation (varies with CPU/compiler):
- 64-bit machine: (15 + 1) * (4 + 2 + 1 + 1 pad) + 8 = 136 bytes
- 32-bit machine: (15 + 1) * (4 + 2 + 1 + 1 pad) + 4 = 132 bytes
-*/
+ * PRIVATE DATA STRUCTURE
+ *
+ * Holds the data for tracking array and map nesting during
+ * encoding. Pairs up with the Nesting_xxx functions to make an
+ * "object" to handle nesting encoding.
+ *
+ * uStart is a uint32_t instead of a size_t to keep the size of this
+ * struct down so it can be on the stack without any concern. It
+ * would be about double if size_t was used instead.
+ *
+ * Size approximation (varies with CPU/compiler):
+ * 64-bit machine: (15 + 1) * (4 + 2 + 1 + 1 pad) + 8 = 136 bytes
+ * 32-bit machine: (15 + 1) * (4 + 2 + 1 + 1 pad) + 4 = 132 bytes
+ */
typedef struct __QCBORTrackNesting {
// PRIVATE DATA STRUCTURE
struct {
@@ -210,21 +203,21 @@
uint16_t uCount; // Number of items in the arrary or map; counts items
// in a map, not pairs of items
uint8_t uMajorType; // Indicates if item is a map or an array
- } pArrays[QCBOR_MAX_ARRAY_NESTING1+1], // stored state for the nesting levels
+ } pArrays[QCBOR_MAX_ARRAY_NESTING+1], // stored state for the nesting levels
*pCurrentNesting; // the current nesting level
} QCBORTrackNesting;
/*
- PRIVATE DATA STRUCTURE
-
- Context / data object for encoding some CBOR. Used by all encode functions to
- form a public "object" that does the job of encdoing.
-
- Size approximation (varies with CPU/compiler):
- 64-bit machine: 27 + 1 (+ 4 padding) + 136 = 32 + 136 = 168 bytes
- 32-bit machine: 15 + 1 + 132 = 148 bytes
-*/
+ * PRIVATE DATA STRUCTURE
+ *
+ * Context / data object for encoding some CBOR. Used by all encode
+ * functions to form a public "object" that does the job of encdoing.
+ *
+ * Size approximation (varies with CPU/compiler):
+ * 64-bit machine: 27 + 1 (+ 4 padding) + 136 = 32 + 136 = 168 bytes
+ * 32-bit machine: 15 + 1 + 132 = 148 bytes
+ */
struct _QCBOREncodeContext {
// PRIVATE DATA STRUCTURE
UsefulOutBuf OutBuf; // Pointer to output buffer, its length and
@@ -235,20 +228,20 @@
/*
- PRIVATE DATA STRUCTURE
-
- Holds the data for array and map nesting for decoding work. This
- structure and the DecodeNesting_Xxx() functions in qcbor_decode.c
- form an "object" that does the work for arrays and maps. All access
- to this structure is through DecodeNesting_Xxx() functions.
-
- 64-bit machine size
- 128 = 16 * 8 for the two unions
- 64 = 16 * 4 for the uLevelType, 1 byte padded to 4 bytes for alignment
- 16 = 16 bytes for two pointers
- 208 TOTAL
-
- 32-bit machine size is 200 bytes
+ * PRIVATE DATA STRUCTURE
+ *
+ * Holds the data for array and map nesting for decoding work. This
+ * structure and the DecodeNesting_Xxx() functions in qcbor_decode.c
+ * form an "object" that does the work for arrays and maps. All access
+ * to this structure is through DecodeNesting_Xxx() functions.
+ *
+ * 64-bit machine size
+ * 128 = 16 * 8 for the two unions
+ * 64 = 16 * 4 for the uLevelType, 1 byte padded to 4 bytes for alignment
+ * 16 = 16 bytes for two pointers
+ * 208 TOTAL
+ *
+ * 32-bit machine size is 200 bytes
*/
typedef struct __QCBORDecodeNesting {
// PRIVATE DATA STRUCTURE
@@ -305,7 +298,7 @@
uint32_t uBstrStartOffset;
} bs; /* for top-level sequence and bstr-wrapped CBOR */
} u;
- } pLevels[QCBOR_MAX_ARRAY_NESTING1+1],
+ } pLevels[QCBOR_MAX_ARRAY_NESTING+1],
*pCurrent,
*pCurrentBounded;
/*
@@ -334,14 +327,14 @@
/*
- PRIVATE DATA STRUCTURE
-
- The decode context. This data structure plus the public QCBORDecode_xxx
- functions form an "object" that does CBOR decoding.
-
- Size approximation (varies with CPU/compiler):
- 64-bit machine: 32 + 1 + 1 + 6 bytes padding + 72 + 16 + 8 + 8 = 144 bytes
- 32-bit machine: 16 + 1 + 1 + 2 bytes padding + 68 + 8 + 8 + 4 = 108 bytes
+ * PRIVATE DATA STRUCTURE
+ *
+ * The decode context. This data structure plus the public QCBORDecode_xxx
+ * functions form an "object" that does CBOR decoding.
+ *
+ * Size approximation (varies with CPU/compiler):
+ * 64-bit machine: 32 + 1 + 1 + 6 bytes padding + 72 + 16 + 8 + 8 = 144 bytes
+ * 32-bit machine: 16 + 1 + 1 + 2 bytes padding + 68 + 8 + 8 + 4 = 108 bytes
*/
struct _QCBORDecodeContext {
// PRIVATE DATA STRUCTURE
@@ -369,7 +362,7 @@
uint8_t uDecodeMode;
uint8_t bStringAllocateAll;
- uint8_t uLastError; // QCBORError stuffed into a uint8_t
+ uint8_t uLastError; /* QCBORError stuffed into a uint8_t */
/* See MapTagNumber() for description of how tags are mapped. */
uint64_t auMappedTags[QCBOR_NUM_MAPPED_TAGS];
@@ -378,12 +371,13 @@
};
-// Used internally in the impementation here
-// Must not conflict with any of the official CBOR types
-#define CBOR_MAJOR_NONE_TYPE_RAW 9
-#define CBOR_MAJOR_NONE_TAG_LABEL_REORDER 10
+/* Used internally in the impementation here
+ * Must not conflict with any of the official CBOR types
+ */
+#define CBOR_MAJOR_NONE_TYPE_RAW 9
+#define CBOR_MAJOR_NONE_TAG_LABEL_REORDER 10
#define CBOR_MAJOR_NONE_TYPE_BSTR_LEN_ONLY 11
-#define CBOR_MAJOR_NONE_TYPE_OPEN_BSTR 12
+#define CBOR_MAJOR_NONE_TYPE_OPEN_BSTR 12
// Add this to types to indicate they are to be encoded as indefinite lengths
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index e913854..fd0f7a4 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -1011,7 +1011,7 @@
UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spTooDeepArrays),
QCBOR_DECODE_MODE_NORMAL);
- for(i = 0; i < QCBOR_MAX_ARRAY_NESTING1; i++) {
+ for(i = 0; i < QCBOR_MAX_ARRAY_NESTING; i++) {
if(QCBORDecode_GetNext(&DCtx, &Item) != 0 ||
Item.uDataType != QCBOR_TYPE_ARRAY ||