Rename private functions to guard against name collisons (#194)
This makes names of functions that link into the target executable longer and more unique. This is doing the job of c++ name spaces.
This makes all the context variable names consistent "pMe" where sometimes "me" was used.
This pulls all the documentation of private functions that were publicly exposed into the .c files.
This cleans up other aspects of function definition/declaration.
Remove "inline" from functions in .c files. Assume that the compilers know better these days.
This adds "const" to arguments of lots of function implementations.
This makes no semantic changes. The generated object code should be identical.
* Rename private functions to avoid name collisons
* line lengths, consistent function naming
* More const
* const and missed rename
---------
Co-authored-by: Laurence Lundblade <lgl@securitytheory.com>
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index 546252a..267b439 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -1,6 +1,6 @@
/*==============================================================================
Copyright (c) 2016-2018, The Linux Foundation.
- Copyright (c) 2018-2021, Laurence Lundblade.
+ Copyright (c) 2018-2024, Laurence Lundblade.
Copyright (c) 2022, Arm Limited. All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -602,13 +602,13 @@
QCBOREncode_CloseMap(pECtx);
/* true / false ... */
- QCBOREncode_AddSimple(pECtx, CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_AddUndef(pECtx);
QCBOREncode_OpenMap(pECtx);
QCBOREncode_AddSZString(pECtx, "dare");
QCBOREncode_AddTag(pECtx, 66);
QCBOREncode_AddBool(pECtx, true);
QCBOREncode_AddBoolToMap(pECtx, "uu", false);
- QCBOREncode_AddSimpleToMapN(pECtx, 737634, CBOR_SIMPLEV_NULL);
+ QCBOREncode_AddNULLToMapN(pECtx, 737634);
QCBOREncode_CloseMap(pECtx);
/* opening an array */
@@ -643,17 +643,17 @@
QCBOREncode_OpenMap(pECtx);
QCBOREncode_AddSZString(pECtx, "s1");
QCBOREncode_AddTag(pECtx, 88);
- QCBOREncode_AddSimple(pECtx, 255);
- QCBOREncode_AddSimpleToMap(pECtx, "s2", 0);
+ QCBOREncode_Private_AddSimple(pECtx, 255);
+ QCBOREncode_Private_AddSimpleToMap(pECtx, "s2", 0);
QCBOREncode_AddSZString(pECtx, "s3");
QCBOREncode_AddTag(pECtx, 88);
- QCBOREncode_AddSimple(pECtx, 33);
+ QCBOREncode_Private_AddSimple(pECtx, 33);
QCBOREncode_AddInt64(pECtx, 88378374); // label before tag
QCBOREncode_AddTag(pECtx, 88);
- QCBOREncode_AddSimple(pECtx, 255);
+ QCBOREncode_Private_AddSimple(pECtx, 255);
QCBOREncode_AddInt64(pECtx, 89); // label before tag
QCBOREncode_AddTag(pECtx, 88);
- QCBOREncode_AddSimple(pECtx, 19);
+ QCBOREncode_Private_AddSimple(pECtx, 19);
QCBOREncode_CloseMap(pECtx);
/* UUIDs */
@@ -912,14 +912,14 @@
QCBOREncode_Init(&ECtx, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
QCBOREncode_OpenArray(&ECtx);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_TRUE);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_FALSE);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_NULL);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_AddBool(&ECtx, true);
+ QCBOREncode_AddBool(&ECtx, false);
+ QCBOREncode_AddNULL(&ECtx);
+ QCBOREncode_AddUndef(&ECtx);
QCBOREncode_OpenMap(&ECtx);
- QCBOREncode_AddSimpleToMap(&ECtx, "UNDef", CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_AddUndefToMap(&ECtx, "UNDef");
QCBOREncode_CloseMap(&ECtx);
QCBOREncode_CloseArray(&ECtx);
@@ -959,14 +959,14 @@
QCBOREncode_Init(&ECtx, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
QCBOREncode_OpenArrayIndefiniteLength(&ECtx);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_TRUE);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_FALSE);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_NULL);
- QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_AddBool(&ECtx, true);
+ QCBOREncode_AddBool(&ECtx, false);
+ QCBOREncode_AddNULL(&ECtx);
+ QCBOREncode_AddUndef(&ECtx);
QCBOREncode_OpenMapIndefiniteLength(&ECtx);
- QCBOREncode_AddSimpleToMap(&ECtx, "UNDef", CBOR_SIMPLEV_UNDEF);
+ QCBOREncode_AddUndefToMap(&ECtx, "UNDef");
QCBOREncode_CloseMapIndefiniteLength(&ECtx);
QCBOREncode_CloseArrayIndefiniteLength(&ECtx);
@@ -1647,7 +1647,7 @@
// The result: 0 if scan happened and found nothing; 1 if it happened and
// found something wrong; 2 if it didn't happen
- QCBOREncode_AddSimpleToMap(&ECtx, "integrity", uRResult);
+ QCBOREncode_Private_AddSimpleToMap(&ECtx, "integrity", uRResult);
// Add the diagnostic code
QCBOREncode_AddSZStringToMap(&ECtx, "type", szType);
@@ -2651,7 +2651,7 @@
/* ------ QCBOR_ERR_UNSUPPORTED -------- */
QCBOREncode_Init(&EC, Large);
QCBOREncode_OpenArray(&EC);
- QCBOREncode_AddSimple(&EC, 24); /* CBOR_SIMPLEV_RESERVED_START */
+ QCBOREncode_Private_AddSimple(&EC, 24); /* CBOR_SIMPLEV_RESERVED_START */
uErr = QCBOREncode_FinishGetSize(&EC, &xx);
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
if(uErr != QCBOR_ERR_ENCODE_UNSUPPORTED) {
@@ -2666,7 +2666,7 @@
QCBOREncode_Init(&EC, Large);
QCBOREncode_OpenArray(&EC);
- QCBOREncode_AddSimple(&EC, 31); /* CBOR_SIMPLEV_RESERVED_END */
+ QCBOREncode_Private_AddSimple(&EC, 31); /* CBOR_SIMPLEV_RESERVED_END */
uErr = QCBOREncode_FinishGetSize(&EC, &xx);
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
if(uErr != QCBOR_ERR_ENCODE_UNSUPPORTED) {