From 33b53c7f5cef4cf19770a38baa4b627f234322cf Mon Sep 17 00:00:00 2001 From: Giovanni Conte Date: Wed, 16 Jan 2019 12:09:43 +0100 Subject: removed longbow dependency Change-Id: I0c224b26261c7b24699410fc5e41ed6f3fab9815 Signed-off-by: Giovanni Conte --- libparc/parc/algol/internal_parc_Event.c | 28 ++++----- libparc/parc/algol/parc_ArrayList.c | 28 ++++----- libparc/parc/algol/parc_Base64.c | 4 +- libparc/parc/algol/parc_BitVector.c | 38 ++++++------ libparc/parc/algol/parc_BitVector.h | 34 +++++------ libparc/parc/algol/parc_Buffer.c | 45 +++++++------- libparc/parc/algol/parc_Buffer.h | 2 +- libparc/parc/algol/parc_BufferComposer.c | 8 +-- libparc/parc/algol/parc_BufferComposer.h | 2 +- libparc/parc/algol/parc_BufferDictionary.c | 20 +++---- libparc/parc/algol/parc_ByteArray.c | 12 ++-- libparc/parc/algol/parc_ByteArray.h | 4 +- libparc/parc/algol/parc_Deque.c | 22 +++---- libparc/parc/algol/parc_Deque.h | 2 +- libparc/parc/algol/parc_Dictionary.c | 38 ++++++------ libparc/parc/algol/parc_DisplayIndented.c | 14 ++--- libparc/parc/algol/parc_Event.c | 16 ++--- libparc/parc/algol/parc_EventBuffer.c | 76 ++++++++++++------------ libparc/parc/algol/parc_EventQueue.c | 26 ++++----- libparc/parc/algol/parc_EventScheduler.c | 20 +++---- libparc/parc/algol/parc_EventSignal.c | 14 ++--- libparc/parc/algol/parc_EventSocket.c | 6 +- libparc/parc/algol/parc_EventTimer.c | 14 ++--- libparc/parc/algol/parc_File.c | 12 ++-- libparc/parc/algol/parc_FileInputStream.c | 4 +- libparc/parc/algol/parc_FileInputStream.h | 2 +- libparc/parc/algol/parc_FileOutputStream.c | 4 +- libparc/parc/algol/parc_FileOutputStream.h | 2 +- libparc/parc/algol/parc_HashCodeTable.c | 36 ++++++------ libparc/parc/algol/parc_HashMap.c | 12 ++-- libparc/parc/algol/parc_Iterator.c | 14 ++--- libparc/parc/algol/parc_Iterator.h | 2 +- libparc/parc/algol/parc_JSON.c | 2 +- libparc/parc/algol/parc_JSONArray.c | 6 +- libparc/parc/algol/parc_JSONArray.h | 2 +- libparc/parc/algol/parc_JSONPair.c | 4 +- libparc/parc/algol/parc_JSONParser.c | 6 +- libparc/parc/algol/parc_JSONParser.h | 2 +- libparc/parc/algol/parc_JSONValue.c | 22 +++---- libparc/parc/algol/parc_JSONValue.h | 2 +- libparc/parc/algol/parc_KeyValue.c | 14 ++--- libparc/parc/algol/parc_KeyedElement.c | 6 +- libparc/parc/algol/parc_LinkedList.c | 22 +++---- libparc/parc/algol/parc_LinkedList.h | 4 +- libparc/parc/algol/parc_List.c | 2 +- libparc/parc/algol/parc_List.h | 4 +- libparc/parc/algol/parc_Memory.c | 4 +- libparc/parc/algol/parc_Network.c | 30 +++++----- libparc/parc/algol/parc_Network.h | 10 ++-- libparc/parc/algol/parc_Object.c | 30 +++++----- libparc/parc/algol/parc_Object.h | 8 +-- libparc/parc/algol/parc_OldSortedList.c | 18 +++--- libparc/parc/algol/parc_PathName.c | 2 +- libparc/parc/algol/parc_PriorityQueue.c | 28 ++++----- libparc/parc/algol/parc_Properties.c | 12 ++-- libparc/parc/algol/parc_RandomAccessFile.c | 8 +-- libparc/parc/algol/parc_SafeMemory.c | 10 ++-- libparc/parc/algol/parc_SafeMemory.h | 2 +- libparc/parc/algol/parc_SortedList.c | 6 +- libparc/parc/algol/parc_Stack.c | 4 +- libparc/parc/algol/parc_StdlibMemory.c | 4 +- libparc/parc/algol/parc_String.c | 4 +- libparc/parc/algol/parc_Time.c | 4 +- libparc/parc/algol/parc_TreeMap.c | 76 ++++++++++++------------ libparc/parc/algol/parc_TreeRedBlack.c | 44 +++++++------- libparc/parc/algol/parc_URI.c | 4 +- libparc/parc/algol/parc_URIAuthority.c | 2 +- libparc/parc/algol/parc_URIPath.c | 8 +-- libparc/parc/algol/parc_URIPath.h | 2 +- libparc/parc/algol/parc_URISegment.c | 10 ++-- libparc/parc/algol/parc_Unsigned.c | 2 +- libparc/parc/algol/parc_Varint.c | 84 +++++++++++++-------------- libparc/parc/algol/parc_Vector.c | 12 ++-- libparc/parc/algol/test/test_parc_ArrayList.c | 5 +- 74 files changed, 546 insertions(+), 546 deletions(-) (limited to 'libparc/parc/algol') diff --git a/libparc/parc/algol/internal_parc_Event.c b/libparc/parc/algol/internal_parc_Event.c index 74e917bf..54c193ea 100755 --- a/libparc/parc/algol/internal_parc_Event.c +++ b/libparc/parc/algol/internal_parc_Event.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include "internal_parc_Event.h" @@ -67,7 +67,7 @@ internal_parc_initializeLibevent(void) // CC = patchlevel // uint32_t version = event_get_version_number(); - trapIllegalValueIf(version < 0x02001000UL, + parcTrapIllegalValueIf(version < 0x02001000UL, "Libevent version must be at least 2.0.16, got %s", event_get_version()); @@ -79,9 +79,9 @@ internal_parc_initializeLibevent(void) // Create a scheduler event base, an event, then free both of them. // struct event_base *evbase = event_base_new(); - assertNotNull(evbase, "Libevent event_base_new returned NULL"); + parcAssertNotNull(evbase, "Libevent event_base_new returned NULL"); struct event *event = event_new(evbase, -1, 0, NULL, NULL); - assertNotNull(event, "Libevent event_new returned NULL"); + parcAssertNotNull(event, "Libevent event_new returned NULL"); event_del(event); event_base_free(evbase); event_free(event); @@ -103,7 +103,7 @@ internal_libevent_priority_to_PARCEventPriority(short evpriority) case 2: priority = PARCEventPriority_Minimum; break; default: - assertTrue(0, "Unknown Libevent priority 0x%x\n", evpriority); + parcAssertTrue(0, "Unknown Libevent priority 0x%x\n", evpriority); break; } return priority; @@ -121,7 +121,7 @@ internal_PARCEventPriority_to_libevent_priority(PARCEventPriority priority) case PARCEventPriority_Minimum: evpriority = 2; break; default: - assertTrue(0, "Unknown PARCEventPriority 0x%x\n", evpriority); + parcAssertTrue(0, "Unknown PARCEventPriority 0x%x\n", evpriority); break; } return evpriority; @@ -139,7 +139,7 @@ internal_eventloop_options_to_PARCEventSchedulerDispatchType(short evoptions) case EVLOOP_NONBLOCK: options = PARCEventSchedulerDispatchType_NonBlocking; break; default: - assertTrue(0, "Unknown Libevent dispatcher flag 0x%x\n", evoptions); + parcAssertTrue(0, "Unknown Libevent dispatcher flag 0x%x\n", evoptions); break; } return options; @@ -157,7 +157,7 @@ internal_PARCEventSchedulerDispatchType_to_eventloop_options(PARCEventSchedulerD case PARCEventSchedulerDispatchType_NonBlocking: evoptions = EVLOOP_NONBLOCK; break; default: - assertTrue(0, "Unknown PARCEventSchedulerDispatchType option 0x%x\n", evoptions); + parcAssertTrue(0, "Unknown PARCEventSchedulerDispatchType option 0x%x\n", evoptions); break; } return evoptions; @@ -175,7 +175,7 @@ internal_bufferevent_options_to_PARCEventQueueOption(short evflags) flags |= PARCEventQueueOption_DeferCallbacks; evflags &= ~BEV_OPT_DEFER_CALLBACKS; } - assertTrue(evflags == 0, "Unknown Libevent option flag 0x%x\n", evflags); + parcAssertTrue(evflags == 0, "Unknown Libevent option flag 0x%x\n", evflags); return flags; } @@ -191,7 +191,7 @@ internal_PARCEventQueueOption_to_bufferevent_options(PARCEventQueueOption flags) evflags |= BEV_OPT_DEFER_CALLBACKS; flags &= ~PARCEventQueueOption_DeferCallbacks; } - assertTrue(flags == 0, "Unknown PARCEventQueueOption flag 0x%x\n", flags); + parcAssertTrue(flags == 0, "Unknown PARCEventQueueOption flag 0x%x\n", flags); return evflags; } @@ -223,7 +223,7 @@ internal_bufferevent_type_to_PARCEventQueueEventType(short evtypes) types |= PARCEventQueueEventType_Connected; evtypes &= ~BEV_EVENT_CONNECTED; } - assertTrue(evtypes == 0, "Unknown Libevent type flag 0x%x\n", evtypes); + parcAssertTrue(evtypes == 0, "Unknown Libevent type flag 0x%x\n", evtypes); return types; } @@ -255,7 +255,7 @@ internal_PARCEventQueueEventType_to_bufferevent_type(PARCEventQueueEventType typ evtypes |= BEV_EVENT_CONNECTED; types &= ~PARCEventQueueEventType_Connected; } - assertTrue(types == 0, "Unknown PARCEventQueueEventType 0x%x\n", types); + parcAssertTrue(types == 0, "Unknown PARCEventQueueEventType 0x%x\n", types); return evtypes; } @@ -287,7 +287,7 @@ internal_libevent_type_to_PARCEventType(short evtypes) types |= PARCEventType_EdgeTriggered; evtypes &= ~EV_ET; } - assertTrue(evtypes == 0, "Unknown Libevent event type 0x%x\n", evtypes); + parcAssertTrue(evtypes == 0, "Unknown Libevent event type 0x%x\n", evtypes); return types; } @@ -319,6 +319,6 @@ internal_PARCEventType_to_libevent_type(PARCEventType types) evtypes |= EV_ET; types &= ~PARCEventType_EdgeTriggered; } - assertTrue(types == 0, "Unknown Libevent event type 0x%x\n", types); + parcAssertTrue(types == 0, "Unknown Libevent event type 0x%x\n", types); return evtypes; } diff --git a/libparc/parc/algol/parc_ArrayList.c b/libparc/parc/algol/parc_ArrayList.c index e9597070..4e6f6df1 100644 --- a/libparc/parc/algol/parc_ArrayList.c +++ b/libparc/parc/algol/parc_ArrayList.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -85,7 +85,7 @@ _ensureCapacity(PARCArrayList *array, size_t newCapacity) static PARCArrayList * _ensureRemaining(PARCArrayList *array, size_t remnant) { - assertNotNull(array, "Parameter must be a non-null PARCArrayList pointer."); + parcAssertNotNull(array, "Parameter must be a non-null PARCArrayList pointer."); if (_remaining(array) < remnant) { size_t newCapacity = parcArrayList_Size(array) + remnant; @@ -111,8 +111,8 @@ parcArrayList_IsValid(const PARCArrayList *instance) void parcArrayList_AssertValid(const PARCArrayList *instance) { - trapIllegalValueIf(instance == NULL, "Parameter must be a non-null PARC_ArrayList pointer."); - assertTrue(instance->numberOfElements == 0 ? true : instance->array != NULL, "PARC_ArrayList size is inconsistent."); + parcTrapIllegalValueIf(instance == NULL, "Parameter must be a non-null PARC_ArrayList pointer."); + parcAssertTrue(instance->numberOfElements == 0 ? true : instance->array != NULL, "PARC_ArrayList size is inconsistent."); } static PARCArrayList * @@ -137,7 +137,7 @@ PARCArrayList * parcArrayList_Create(void (*destroyElement)(void **element)) { PARCArrayList *result = parcMemory_AllocateAndClear(sizeof(PARCArrayList)); - assertNotNull(result, "Memory allocation of PARCArrayList failed"); + parcAssertNotNull(result, "Memory allocation of PARCArrayList failed"); return _parcArrayList_Init(result, 0, 0, NULL, NULL, destroyElement); } @@ -146,7 +146,7 @@ PARCArrayList * parcArrayList_Create_Capacity(bool (*equalsElement)(void *x, void *y), void (*destroyElement)(void **element), size_t size) { PARCArrayList *result = parcMemory_AllocateAndClear(sizeof(PARCArrayList)); - assertNotNull(result, "Memory allocation of PARCArrayList failed"); + parcAssertNotNull(result, "Memory allocation of PARCArrayList failed"); _parcArrayList_Init(result, 0, 0, NULL, equalsElement, destroyElement); @@ -163,7 +163,7 @@ parcArrayList_Add(PARCArrayList *array, const void *pointer) parcArrayList_OptionalAssertValid(array); if (_ensureRemaining(array, 1) == NULL) { - trapOutOfMemory("Cannot increase space for PARCArrayList."); + parcTrapOutOfMemory("Cannot increase space for PARCArrayList."); } array->array[array->numberOfElements++] = (void *) pointer; @@ -221,7 +221,7 @@ parcArrayList_Equals(const PARCArrayList *a, const PARCArrayList *b) void * parcArrayList_RemoveAtIndex(PARCArrayList *array, size_t index) { - trapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements); + parcTrapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements); void *element = array->array[index]; @@ -237,7 +237,7 @@ parcArrayList_RemoveAtIndex(PARCArrayList *array, size_t index) void parcArrayList_Set(const PARCArrayList *array, size_t index, void *pointer) { - trapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements); + parcTrapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements); array->array[index] = pointer; } @@ -245,7 +245,7 @@ parcArrayList_Set(const PARCArrayList *array, size_t index, void *pointer) void * parcArrayList_Get(const PARCArrayList *array, size_t index) { - trapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements); + parcTrapOutOfBoundsIf(index >= array->numberOfElements, "Index must be within the range [0, %zu)", array->numberOfElements); return array->array[index]; } @@ -265,13 +265,13 @@ parcArrayList_Size(const PARCArrayList *pointerArray) void parcArrayList_Destroy(PARCArrayList **arrayPtr) { - assertNotNull(arrayPtr, "Parameter must be a non-null pointer to a PARC_ArrayList pointer."); + parcAssertNotNull(arrayPtr, "Parameter must be a non-null pointer to a PARC_ArrayList pointer."); PARCArrayList *array = *arrayPtr; parcArrayList_OptionalAssertValid(array); - assertTrue(array->numberOfElements == 0 ? true : array->array != NULL, "PARC_ArrayList is inconsistent."); + parcAssertTrue(array->numberOfElements == 0 ? true : array->array != NULL, "PARC_ArrayList is inconsistent."); if (array->destroyElement != NULL) { for (size_t i = 0; i < array->numberOfElements; i++) { @@ -328,7 +328,7 @@ parcArrayList_RemoveAndDestroyAtIndex(PARCArrayList *array, size_t index) { parcArrayList_OptionalAssertValid(array); - assertTrue(index < array->numberOfElements, "Index must be ( 0 <= index < %zd). Actual=%zd", array->numberOfElements, index); + parcAssertTrue(index < array->numberOfElements, "Index must be ( 0 <= index < %zd). Actual=%zd", array->numberOfElements, index); if (index < array->numberOfElements) { // Destroy the element at the given index. @@ -352,7 +352,7 @@ parcArrayList_InsertAtIndex(PARCArrayList *array, size_t index, const void *poin parcArrayList_OptionalAssertValid(array); size_t length = parcArrayList_Size(array); - assertTrue(index <= array->numberOfElements, "You can't insert beyond the end of the list"); + parcAssertTrue(index <= array->numberOfElements, "You can't insert beyond the end of the list"); // Create space and grow the array if needed _ensureRemaining(array, length + 1); diff --git a/libparc/parc/algol/parc_Base64.c b/libparc/parc/algol/parc_Base64.c index 38020479..cac0aa4d 100755 --- a/libparc/parc/algol/parc_Base64.c +++ b/libparc/parc/algol/parc_Base64.c @@ -39,7 +39,7 @@ #include #include -#include +#include #include #include @@ -80,7 +80,7 @@ const uint8_t decodeTable[256] = { static void _encodeWithPad(PARCBufferComposer *output, const uint8_t *quantum, size_t padLength) { - assertTrue(padLength < 3, "Degenerate case -- should never pad all 3 bytes!"); + parcAssertTrue(padLength < 3, "Degenerate case -- should never pad all 3 bytes!"); unsigned index; diff --git a/libparc/parc/algol/parc_BitVector.c b/libparc/parc/algol/parc_BitVector.c index 578fd102..21a66c23 100755 --- a/libparc/parc/algol/parc_BitVector.c +++ b/libparc/parc/algol/parc_BitVector.c @@ -13,11 +13,9 @@ * limitations under the License. */ -/** - */ #include -#include +#include #include #include @@ -61,10 +59,10 @@ PARCBitVector * parcBitVector_Create(void) { PARCBitVector *parcBitVector = parcObject_CreateInstance(PARCBitVector); - assertNotNull(parcBitVector, "parcObject_CreateInstance returned NULL"); + parcAssertNotNull(parcBitVector, "parcObject_CreateInstance returned NULL"); parcBitVector->bitArray = parcMemory_AllocateAndClear(DEFAULT_BITARRAY_SIZE); - assertNotNull(parcBitVector->bitArray, "parcMemory_AllocateAndClear(%d) returned NULL", DEFAULT_BITARRAY_SIZE); + parcAssertNotNull(parcBitVector->bitArray, "parcMemory_AllocateAndClear(%d) returned NULL", DEFAULT_BITARRAY_SIZE); parcBitVector->bitLength = DEFAULT_BITARRAY_SIZE * BITS_PER_BYTE; parcBitVector->numberOfBitsSet = 0; parcBitVector->firstBitSet = -1; @@ -77,7 +75,7 @@ PARCBitVector * parcBitVector_Copy(const PARCBitVector *source) { PARCBitVector *parcBitVector = parcObject_CreateInstance(PARCBitVector); - assertNotNull(parcBitVector, "parcObject_CreateInstance returned NULL"); + parcAssertNotNull(parcBitVector, "parcObject_CreateInstance returned NULL"); size_t byteLength = source->bitLength / BITS_PER_BYTE; parcBitVector->bitArray = parcMemory_Allocate(byteLength); @@ -111,8 +109,8 @@ parcBitVector_Equals(const PARCBitVector *a, const PARCBitVector *b) static void _parc_bit_vector_resize(PARCBitVector *parcBitVector, unsigned bit) { - assertNotNull(parcBitVector, "_parc_bit_vector_resize passed a NULL parcBitVector"); - assertTrue(bit < MAX_BIT_VECTOR_INDEX, "_parc_bit_vector_resize passed a bit index that's too large"); + parcAssertNotNull(parcBitVector, "_parc_bit_vector_resize passed a NULL parcBitVector"); + parcAssertTrue(bit < MAX_BIT_VECTOR_INDEX, "_parc_bit_vector_resize passed a bit index that's too large"); unsigned neededBits = bit + 1; if (neededBits > parcBitVector->bitLength) { @@ -120,12 +118,12 @@ _parc_bit_vector_resize(PARCBitVector *parcBitVector, unsigned bit) int oldSize = (parcBitVector->bitLength / BITS_PER_BYTE) + ((parcBitVector->bitLength % BITS_PER_BYTE) ? 1 : 0); uint8_t *newArray = parcMemory_Reallocate(parcBitVector->bitArray, newSize); - assertTrue(newArray, "parcMemory_Reallocate(%d) failed", newSize); + parcAssertTrue(newArray, "parcMemory_Reallocate(%d) failed", newSize); // Reallocate does not guarantee that additional memory is zero-filled. memset((void *) &(newArray[oldSize]), parcBitVector->fillValue, newSize - oldSize); parcBitVector->bitArray = newArray; - assertNotNull(newArray, "parcMemory_Reallocate(%d) returned NULL", newSize); + parcAssertNotNull(newArray, "parcMemory_Reallocate(%d) returned NULL", newSize); parcBitVector->bitLength = newSize * BITS_PER_BYTE; } } @@ -133,7 +131,7 @@ _parc_bit_vector_resize(PARCBitVector *parcBitVector, unsigned bit) int parcBitVector_Get(const PARCBitVector *parcBitVector, unsigned bit) { - assertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Set passed a bit index that's too large"); + parcAssertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Set passed a bit index that's too large"); if ((parcBitVector == NULL) || (bit >= parcBitVector->bitLength)) { return -1; @@ -151,8 +149,8 @@ parcBitVector_Get(const PARCBitVector *parcBitVector, unsigned bit) void parcBitVector_Set(PARCBitVector *parcBitVector, unsigned bit) { - assertNotNull(parcBitVector, "parcBitVector_Set passed a NULL parcBitVector"); - assertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Set passed a bit index that's too huge"); + parcAssertNotNull(parcBitVector, "parcBitVector_Set passed a NULL parcBitVector"); + parcAssertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Set passed a bit index that's too huge"); if (bit >= parcBitVector->bitLength) { _parc_bit_vector_resize(parcBitVector, bit); } @@ -170,12 +168,12 @@ parcBitVector_Set(PARCBitVector *parcBitVector, unsigned bit) void parcBitVector_SetVector(PARCBitVector *parcBitVector, const PARCBitVector *bitsToSet) { - assertNotNull(parcBitVector, "parcBitVector_SetVector passed a NULL parcBitVector"); - assertNotNull(parcBitVector, "parcBitVector_SetVector passed a NULL vector of bits to set"); + parcAssertNotNull(parcBitVector, "parcBitVector_SetVector passed a NULL parcBitVector"); + parcAssertNotNull(parcBitVector, "parcBitVector_SetVector passed a NULL vector of bits to set"); int settingBit = 0; for (int i = 0; i < bitsToSet->numberOfBitsSet; i++) { settingBit = parcBitVector_NextBitSet(bitsToSet, settingBit); - assertTrue(settingBit != -1, "Number of bits claimed set inconsistent with bits found"); + parcAssertTrue(settingBit != -1, "Number of bits claimed set inconsistent with bits found"); parcBitVector_Set(parcBitVector, settingBit); settingBit++; } @@ -194,8 +192,8 @@ parcBitVector_Reset(PARCBitVector *parcBitVector) void parcBitVector_Clear(PARCBitVector *parcBitVector, unsigned bit) { - assertNotNull(parcBitVector, "parcBitVector_Clear passed a NULL parcBitVector"); - assertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Clear passed a bit index that's too huge"); + parcAssertNotNull(parcBitVector, "parcBitVector_Clear passed a NULL parcBitVector"); + parcAssertTrue(bit < MAX_BIT_VECTOR_INDEX, "parcBitVector_Clear passed a bit index that's too huge"); if (bit > parcBitVector->bitLength) { _parc_bit_vector_resize(parcBitVector, bit); } @@ -213,8 +211,8 @@ parcBitVector_Clear(PARCBitVector *parcBitVector, unsigned bit) void parcBitVector_ClearVector(PARCBitVector *parcBitVector, const PARCBitVector *bitsToClear) { - assertNotNull(parcBitVector, "parcBitVector_ClearVector passed a NULL parcBitVector"); - assertNotNull(bitsToClear, "parcBitVector_ClearVector passed a NULL for vector of bitsToClear"); + parcAssertNotNull(parcBitVector, "parcBitVector_ClearVector passed a NULL parcBitVector"); + parcAssertNotNull(bitsToClear, "parcBitVector_ClearVector passed a NULL for vector of bitsToClear"); // If we're clearing ourself, we just need a reset if (parcBitVector == bitsToClear) { diff --git a/libparc/parc/algol/parc_BitVector.h b/libparc/parc/algol/parc_BitVector.h index 7e72ac70..552fd911 100755 --- a/libparc/parc/algol/parc_BitVector.h +++ b/libparc/parc/algol/parc_BitVector.h @@ -57,7 +57,7 @@ PARCBitVector *parcBitVector_Create(void); * PARCBitVector *parcBitVector = parcBitVector_Create(); * parcBitVector_Set(parcBitVector, 10); * PARCBitVector *copy = parcBitVector_Copy(parcBitVector); - * assertTrue(parcBitVector_Equals(parcBitVector, copy), "Duplicate vector is unequal"); + * parcAssertTrue(parcBitVector_Equals(parcBitVector, copy), "Duplicate vector is unequal"); * } * @endcode * @@ -115,7 +115,7 @@ void parcBitVector_Release(PARCBitVector **parcBitVector); * parcBitVector_Set(parcBitVector, 10); * PARCBitVector *copy = parcBitVector_Copy(parcBitVector); * parcBitVector_Set(copy, 1); - * assertTrue(parcBitVector_Equals(parcBitVector, copy) == false, "Vector should have been unequal"); + * parcAssertTrue(parcBitVector_Equals(parcBitVector, copy) == false, "Vector should have been unequal"); * } * @endcode * @@ -138,7 +138,7 @@ bool parcBitVector_Equals(const PARCBitVector *a, const PARCBitVector *b); * parcBitVector_Set(superSet, 11); * PARCBitVector *subSet = parcBitVector_Create(); * parcBitVector_Set(subSet, 10); - * assertTrue(parcBitVector_Contains(superSet, subSet), "Expect superSet to contain subSet"); + * parcAssertTrue(parcBitVector_Contains(superSet, subSet), "Expect superSet to contain subSet"); * } * @endcode * @@ -157,7 +157,7 @@ bool parcBitVector_Contains(const PARCBitVector *parcBitVector, const PARCBitVec * { * PARCBitVector *parcBitVector = parcBitVector_Create(); * parcBitVector_Set(parcBitVector, 10); - * assertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set"); + * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set"); * } * @endcode * @@ -175,7 +175,7 @@ int parcBitVector_Get(const PARCBitVector *parcBitVector, unsigned bit); * { * PARCBitVector *parcBitVector = parcBitVector_Create(); * parcBitVector_Set(parcBitVector, 10); - * assertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set"); + * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set"); * } * @endcode * @@ -196,7 +196,7 @@ void parcBitVector_Set(PARCBitVector *parcBitVector, unsigned bit); * parcBitVector_Set(parcBitVector, 0); * * parcBitVector_RightShift(parcBitVector, 1); - * assertTrue(parcBitVector_FirstBitSet(parcBitVector) == 1, + * parcAssertTrue(parcBitVector_FirstBitSet(parcBitVector) == 1, * "First vector element should have moved up"); * * parcBitVector_Release(&parcBitVector); @@ -221,7 +221,7 @@ PARCBitVector *parcBitVector_RightShift(PARCBitVector *parcBitVector, size_t rig * parcBitVector_Set(parcBitVector, 0); * * parcBitVector_LeftShift(parcBitVector, 1); - * assertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 1, + * parcAssertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 1, * "First vector element should have rolled off"); * * parcBitVector_Release(&parcBitVector); @@ -247,7 +247,7 @@ PARCBitVector *parcBitVector_LeftShift(PARCBitVector *parcBitVector, size_t left * parcBitVector_Set(andVector, 11); * * PARCBitVector *result = parcBitVector_And(parcBitVector, andVector); - * assertTrue(parcBitVector_NumberOfBitsSet(result) == 0, "Vector should have been empty"); + * parcAssertTrue(parcBitVector_NumberOfBitsSet(result) == 0, "Vector should have been empty"); * * parcBitVector_Release(&parcBitVector); * parcBitVector_Release(&andVector); @@ -274,7 +274,7 @@ PARCBitVector *parcBitVector_And(const PARCBitVector *a, const PARCBitVector *b) * parcBitVector_Set(orVector, 11); * * PARCBitVector *result = parcBitVector_Or(parcBitVector, orVector); - * assertTrue(parcBitVector_NumberOfBitsSet(result) == 2, "Vector should have been set"); + * parcAssertTrue(parcBitVector_NumberOfBitsSet(result) == 2, "Vector should have been set"); * * parcBitVector_Release(&parcBitVector); * parcBitVector_Release(&orVector); @@ -298,7 +298,7 @@ PARCBitVector *parcBitVector_Or(const PARCBitVector *a, const PARCBitVector *b); * PARCBitVector *bitsToSet = parcBitVector_Create(); * parcBitVector_Set(bitsToSet, 10); * parcBitVector_SetVector(parcBitVector, bitsToSet); - * assertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set"); + * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set"); * } * @endcode * @@ -317,7 +317,7 @@ void parcBitVector_SetVector(PARCBitVector *parcBitVector, const PARCBitVector * * parcBitVector_Set(parcBitVector, 10); * parcBitVector_Set(parcBitVector, 42); * parcBitVector_Reset(parcBitVector); - * assertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 0, "Vector should have 0 bits set"); + * parcAssertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 0, "Vector should have 0 bits set"); * } * @endcode * @@ -335,9 +335,9 @@ void parcBitVector_Reset(PARCBitVector *parcBitVector); * { * PARCBitVector *parcBitVector = parcBitVector_Create(); * parcBitVector_Set(parcBitVector, 10); - * assertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set"); + * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 1, "Vector should have been set"); * parcBitVector_Clear(parcBitVector, 10); - * assertTrue(parcBitVector_Get(parcBitVector, 10) == 0, "Vector should have been cleared"); + * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 0, "Vector should have been cleared"); * } * @endcode * @@ -358,7 +358,7 @@ void parcBitVector_Clear(PARCBitVector *parcBitVector, unsigned bit); * PARCBitVector *bitsToClear = parcBitVector_Create(); * parcBitVector_Set(bitsToClear, 10); * parcBitVector_SetVector(parcBitVector, bitsToClear); - * assertTrue(parcBitVector_Get(parcBitVector, 10) == 0, "Vector should have been cleared"); + * parcAssertTrue(parcBitVector_Get(parcBitVector, 10) == 0, "Vector should have been cleared"); * } * @endcode * @@ -376,7 +376,7 @@ void parcBitVector_ClearVector(PARCBitVector *parcBitVector, const PARCBitVector * { * PARCBitVector *parcBitVector = parcBitVector_Create(); * parcBitVector_Set(parcBitVector, 10); - * assertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 1, "One bit should have been set"); + * parcAssertTrue(parcBitVector_NumberOfBitsSet(parcBitVector) == 1, "One bit should have been set"); * } * @endcode * @@ -396,8 +396,8 @@ unsigned parcBitVector_NumberOfBitsSet(const PARCBitVector *parcBitVector); * PARCBitVector *parcBitVector = parcBitVector_Create(); * parcBitVector_Set(parcBitVector, 10); * parcBitVector_Set(parcBitVector, 12); - * assertTrue(parcBitVector_NextBitSet(parcBitVector, 0) == 10, "Bit 10 should have been found first"); - * assertTrue(parcBitVector_NextBitSet(parcBitVector, 11) == 12, "Bit 12 should have been found next"); + * parcAssertTrue(parcBitVector_NextBitSet(parcBitVector, 0) == 10, "Bit 10 should have been found first"); + * parcAssertTrue(parcBitVector_NextBitSet(parcBitVector, 11) == 12, "Bit 12 should have been found next"); * } * @endcode * diff --git a/libparc/parc/algol/parc_Buffer.c b/libparc/parc/algol/parc_Buffer.c index b2ca3577..20520f9c 100755 --- a/libparc/parc/algol/parc_Buffer.c +++ b/libparc/parc/algol/parc_Buffer.c @@ -18,8 +18,7 @@ #include #include -#include -#include +#include #include #include @@ -65,8 +64,8 @@ _markIsDiscarded(const PARCBuffer *buffer) static inline void _trapIfIndexExceedsLimit(const PARCBuffer *buffer, const size_t index) { - trapOutOfBoundsIf(index > buffer->limit, "PARCBuffer limit at %zd, attempted to access at %zd", - parcBuffer_Limit(buffer), index); + //parcTrapOutOfBoundsIf(index > buffer->limit, "PARCBuffer limit at %zd, attempted to access at %zd", + // parcBuffer_Limit(buffer), index); } static inline void @@ -96,15 +95,15 @@ static inline void _assertInvariants(const PARCBuffer *buffer) { // 0 <= mark <= position <= limit <= capacity - assertTrue(0 <= buffer->mark, + parcAssertTrue(0 <= buffer->mark, "Expected 0 <= mark (%zd)", buffer->mark); - assertTrue(_markIsDiscarded(buffer) || buffer->mark <= buffer->position, + parcAssertTrue(_markIsDiscarded(buffer) || buffer->mark <= buffer->position, "Expected mark (%zd) <= position (%zd)", buffer->mark, buffer->position); - assertTrue(buffer->position <= buffer->limit, + parcAssertTrue(buffer->position <= buffer->limit, "Expected position (%zd) <= limit (%zd)", buffer->position, buffer->limit); - assertTrue(buffer->limit <= buffer->capacity, + parcAssertTrue(buffer->limit <= buffer->capacity, "Expected limit (%zd) <= capacity (%zd)", buffer->limit, buffer->capacity); - assertTrue((buffer->arrayOffset + buffer->capacity) <= parcByteArray_Capacity(buffer->array), + parcAssertTrue((buffer->arrayOffset + buffer->capacity) <= parcByteArray_Capacity(buffer->array), "Expected (%zd + %zd) <= %zd", buffer->arrayOffset, buffer->capacity, parcByteArray_Capacity(buffer->array)); } @@ -201,7 +200,7 @@ parcBuffer_AssertValid(const PARCBuffer *buffer) { char *explanation = _parcBuffer_CheckValidity(buffer); - trapIllegalValueIf(explanation != NULL, "PARCBuffer@%p %s.", (void *) buffer, explanation); + parcTrapIllegalValueIf(explanation != NULL, "PARCBuffer@%p %s.", (void *) buffer, explanation); } bool @@ -450,7 +449,7 @@ parcBuffer_ParseHexString(const char *hexString) PARCBuffer * parcBuffer_CreateFromArray(const void *bytes, const size_t length) { - assertTrue(length == 0 || bytes != NULL, + parcAssertTrue(length == 0 || bytes != NULL, "If the byte array is NULL, then length MUST be zero."); PARCBuffer *result = parcBuffer_Allocate(length); @@ -587,7 +586,7 @@ parcBuffer_Reset(PARCBuffer *buffer) { parcBuffer_OptionalAssertValid(buffer); - assertFalse(_markIsDiscarded(buffer), + parcAssertFalse(_markIsDiscarded(buffer), "The mark has not been set"); buffer->position = buffer->mark; @@ -618,7 +617,7 @@ PARCBuffer * parcBuffer_SetLimit(PARCBuffer *buffer, size_t newLimit) { parcBuffer_OptionalAssertValid(buffer); - assertTrue(newLimit <= parcBuffer_Capacity(buffer), + parcAssertTrue(newLimit <= parcBuffer_Capacity(buffer), "new limit cannot be larger than the capacity"); if (_markIsDiscarded(buffer)) { @@ -666,7 +665,7 @@ parcBuffer_SetPosition(PARCBuffer *buffer, size_t newPosition) { parcBuffer_OptionalAssertValid(buffer); - assertFalse(newPosition > buffer->limit, + parcAssertFalse(newPosition > buffer->limit, "new position cannot be greater the buffer's limit"); buffer->position = newPosition; @@ -808,7 +807,7 @@ PARCBuffer * parcBuffer_PutUint8(PARCBuffer *buffer, uint8_t value) { parcBuffer_OptionalAssertValid(buffer); - assertTrue(parcBuffer_Remaining(buffer) >= 1, + parcAssertTrue(parcBuffer_Remaining(buffer) >= 1, "Buffer overflow"); parcByteArray_PutByte(buffer->array, _effectivePosition(buffer), value); @@ -819,7 +818,7 @@ parcBuffer_PutUint8(PARCBuffer *buffer, uint8_t value) PARCBuffer * parcBuffer_PutUint16(PARCBuffer *buffer, uint16_t value) { - assertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint16_t), + parcAssertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint16_t), "Buffer overflow"); parcBuffer_PutUint8(buffer, (value >> 8) & 0xFF); @@ -830,7 +829,7 @@ parcBuffer_PutUint16(PARCBuffer *buffer, uint16_t value) PARCBuffer * parcBuffer_PutUint32(PARCBuffer *buffer, uint32_t value) { - assertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint32_t), + parcAssertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint32_t), "Buffer overflow"); for (int i = sizeof(uint32_t) - 1; i > 0; i--) { uint8_t b = value >> (i * 8) & 0xFF; @@ -843,7 +842,7 @@ parcBuffer_PutUint32(PARCBuffer *buffer, uint32_t value) PARCBuffer * parcBuffer_PutUint64(PARCBuffer *buffer, uint64_t value) { - assertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint64_t), + parcAssertTrue(parcBuffer_Remaining(buffer) >= sizeof(uint64_t), "Buffer overflow"); for (int i = sizeof(uint64_t) - 1; i > 0; i--) { uint8_t b = value >> (i * 8) & 0xFF; @@ -857,7 +856,7 @@ PARCBuffer * parcBuffer_PutAtIndex(PARCBuffer *buffer, size_t index, uint8_t value) { parcBuffer_OptionalAssertValid(buffer); - assertTrue(_effectiveIndex(buffer, index) < parcBuffer_Limit(buffer), "Buffer overflow"); + parcAssertTrue(_effectiveIndex(buffer, index) < parcBuffer_Limit(buffer), "Buffer overflow"); parcByteArray_PutByte(buffer->array, _effectiveIndex(buffer, index), value); return buffer; @@ -867,7 +866,7 @@ PARCBuffer * parcBuffer_PutArray(PARCBuffer *buffer, size_t arrayLength, const uint8_t array[arrayLength]) { parcBuffer_OptionalAssertValid(buffer); - assertTrue(parcBuffer_Remaining(buffer) >= arrayLength, + parcAssertTrue(parcBuffer_Remaining(buffer) >= arrayLength, "Buffer overflow"); parcByteArray_PutBytes(buffer->array, _effectivePosition(buffer), arrayLength, array); @@ -884,7 +883,7 @@ PARCBuffer * parcBuffer_PutBuffer(PARCBuffer *result, const PARCBuffer *buffer) { parcBuffer_OptionalAssertValid(buffer); - assertTrue(parcBuffer_Remaining(result) >= parcBuffer_Remaining(buffer), + parcAssertTrue(parcBuffer_Remaining(result) >= parcBuffer_Remaining(buffer), "Buffer overflow. %zd bytes remaining, %zd required.", parcBuffer_Remaining(result), parcBuffer_Remaining(buffer)); size_t length = parcBuffer_Remaining(buffer); @@ -923,7 +922,7 @@ parcBuffer_ToString(const PARCBuffer *buffer) char *result = parcMemory_Allocate(remaining + 1); if (remaining > 0) { - assertNotNull(result, "parcMemory_Allocate returned NULL"); + parcAssertNotNull(result, "parcMemory_Allocate returned NULL"); if (result != NULL) { memcpy(result, parcBuffer_Overlay((PARCBuffer *) buffer, 0), remaining); } @@ -965,7 +964,7 @@ parcBuffer_ToHexString(const PARCBuffer *buffer) // Hopefully length is less than (2^(sizeof(size_t)*8) / 2) char *result = parcMemory_AllocateAndClear((length * 2) + 1); - assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", (length * 2) + 1); + parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", (length * 2) + 1); for (size_t i = 0; i < length; i++) { unsigned char byte = parcBuffer_GetAtIndex(buffer, i); diff --git a/libparc/parc/algol/parc_Buffer.h b/libparc/parc/algol/parc_Buffer.h index 2c7f56fd..665019db 100644 --- a/libparc/parc/algol/parc_Buffer.h +++ b/libparc/parc/algol/parc_Buffer.h @@ -140,7 +140,7 @@ extern parcObjectDescriptor_Declaration(PARCBuffer); /** * Assert that an instance of `PARCBuffer` is valid. * - * If the instance is not valid, terminate via `trapIllegalValue()` + * If the instance is not valid, terminate via `parcTrapIllegalValue()` * * Valid means the internal state of the type is consistent with its required current or future behaviour. * This may include the validation of internal instances of types. diff --git a/libparc/parc/algol/parc_BufferComposer.c b/libparc/parc/algol/parc_BufferComposer.c index 20b7ecee..30e23acf 100755 --- a/libparc/parc/algol/parc_BufferComposer.c +++ b/libparc/parc/algol/parc_BufferComposer.c @@ -18,7 +18,7 @@ #include -#include +#include #include #include @@ -91,8 +91,8 @@ _ensureRemaining(PARCBufferComposer *composer, size_t required) void parcBufferComposer_AssertValid(const PARCBufferComposer *composer) { - trapIllegalValueIf(composer == NULL, "Parameter must be a non-null pointer to a valid PARCBufferComposer."); - trapIllegalValueIf(composer->incrementHeuristic < sizeof(void *), "Heuristic cannot be < sizeof(void *) (%zd), actual %zd", sizeof(void *), composer->incrementHeuristic); + parcTrapIllegalValueIf(composer == NULL, "Parameter must be a non-null pointer to a valid PARCBufferComposer."); + parcTrapIllegalValueIf(composer->incrementHeuristic < sizeof(void *), "Heuristic cannot be < sizeof(void *) (%zd), actual %zd", sizeof(void *), composer->incrementHeuristic); } PARCBufferComposer * @@ -250,7 +250,7 @@ parcBufferComposer_Format(PARCBufferComposer *composer, const char *format, ...) va_start(ap, format); char *cString; ssize_t written = vasprintf(&cString, format, ap); - assertTrue(written >= 0, "Got error from vasprintf"); + parcAssertTrue(written >= 0, "Got error from vasprintf"); va_end(ap); parcBufferComposer_PutString(composer, cString); diff --git a/libparc/parc/algol/parc_BufferComposer.h b/libparc/parc/algol/parc_BufferComposer.h index f45aeb8e..25c69258 100755 --- a/libparc/parc/algol/parc_BufferComposer.h +++ b/libparc/parc/algol/parc_BufferComposer.h @@ -83,7 +83,7 @@ PARCBufferComposer *parcBufferComposer_Allocate(size_t length); /** * Assert that an instance of `PARCBufferComposer` is valid. * - * If the instance is not valid, terminate via `trapIllegalValue()`. + * If the instance is not valid, terminate via `parcTrapIllegalValue()`. * * Valid means the internal state of the type is consistent with its required current or future behaviour. * This may include the validation of internal instances of types. diff --git a/libparc/parc/algol/parc_BufferDictionary.c b/libparc/parc/algol/parc_BufferDictionary.c index 56ed800a..c2438129 100755 --- a/libparc/parc/algol/parc_BufferDictionary.c +++ b/libparc/parc/algol/parc_BufferDictionary.c @@ -21,7 +21,7 @@ */ #include -#include +#include #include @@ -73,8 +73,8 @@ _init(PARCBufferDictionary *result) static void _destroy(PARCBufferDictionary **dictionaryPtr) { - assertNotNull(dictionaryPtr, "Double pointer dictionaryPtr must be non-NULL"); - assertNotNull(*dictionaryPtr, "Double pointer dictionaryPtr must dereference to non-NULL"); + parcAssertNotNull(dictionaryPtr, "Double pointer dictionaryPtr must be non-NULL"); + parcAssertNotNull(*dictionaryPtr, "Double pointer dictionaryPtr must dereference to non-NULL"); PARCBufferDictionary *dict = *dictionaryPtr; @@ -102,9 +102,9 @@ parcObject_ImplementRelease(parcBufferDictionary, PARCBufferDictionary); PARCBuffer * parcBufferDictionary_Put(PARCBufferDictionary *dictionary, PARCBuffer *key, PARCBuffer *value) { - assertNotNull(dictionary, "Parameter dictionary must be non-NULL"); - assertNotNull(key, "Parameter key must be non-NULL"); - assertNotNull(value, "Parameter value must be non-NULL"); + parcAssertNotNull(dictionary, "Parameter dictionary must be non-NULL"); + parcAssertNotNull(key, "Parameter key must be non-NULL"); + parcAssertNotNull(value, "Parameter value must be non-NULL"); PARCBuffer *oldValue = NULL; @@ -126,8 +126,8 @@ parcBufferDictionary_Put(PARCBufferDictionary *dictionary, PARCBuffer *key, PARC PARCBuffer * parcBufferDictionary_Get(PARCBufferDictionary *dictionary, PARCBuffer *key) { - assertNotNull(dictionary, "Parameter dictionary must be non-NULL"); - assertNotNull(key, "Parameter key must be non-NULL"); + parcAssertNotNull(dictionary, "Parameter dictionary must be non-NULL"); + parcAssertNotNull(key, "Parameter key must be non-NULL"); return parcHashCodeTable_Get(dictionary->hashtable, key); } @@ -135,8 +135,8 @@ parcBufferDictionary_Get(PARCBufferDictionary *dictionary, PARCBuffer *key) PARCBuffer * parcBufferDictionary_Remove(PARCBufferDictionary *dictionary, PARCBuffer *key) { - assertNotNull(dictionary, "Parameter dictionary must be non-NULL"); - assertNotNull(key, "Parameter key must be non-NULL"); + parcAssertNotNull(dictionary, "Parameter dictionary must be non-NULL"); + parcAssertNotNull(key, "Parameter key must be non-NULL"); // parcHashCodeTable_Del will free the referece, to make a copy of it PARCBuffer *original = (PARCBuffer *) parcHashCodeTable_Get(dictionary->hashtable, key); diff --git a/libparc/parc/algol/parc_ByteArray.c b/libparc/parc/algol/parc_ByteArray.c index 762421bd..1d81d211 100644 --- a/libparc/parc/algol/parc_ByteArray.c +++ b/libparc/parc/algol/parc_ByteArray.c @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -39,7 +39,7 @@ struct parc_byte_array { static inline void _trapIfOutOfBounds(const PARCByteArray *array, const size_t index) { - trapOutOfBoundsIf(index >= array->length, "parcByteArray index %zd exceeds the length %zd", index, array->length); + parcTrapOutOfBoundsIf(index >= array->length, "parcByteArray index %zd exceeds the length %zd", index, array->length); } static bool @@ -66,7 +66,7 @@ parcObject_Override(PARCByteArray, PARCObject, void parcByteArray_AssertValid(const PARCByteArray *instance) { - trapInvalidValueIf(parcByteArray_IsValid(instance) == false, + parcTrapInvalidValueIf(parcByteArray_IsValid(instance) == false, "PARCByteArray instance is invalid."); } @@ -212,12 +212,12 @@ PARCByteArray * parcByteArray_PutBytes(PARCByteArray *result, size_t offset, size_t length, const uint8_t source[length]) { parcByteArray_OptionalAssertValid(result); - trapOutOfBoundsIf(offset > result->length, + parcTrapOutOfBoundsIf(offset > result->length, "The offset (%zd) exeeds the length (%zd) of the PARCByteArray.", offset, result->length); size_t available = result->length - offset; - trapOutOfBoundsIf(length > available, "%zd available bytes, %zd required.", available, length); + parcTrapOutOfBoundsIf(length > available, "%zd available bytes, %zd required.", available, length); memcpy(&result->array[offset], source, length); return result; @@ -230,7 +230,7 @@ parcByteArray_GetBytes(const PARCByteArray *result, size_t offset, size_t length size_t available = result->length - offset; - trapOutOfBoundsIf(length > available, "parcByteArray_CopyOut %zd available bytes, %zd required", available, length); + parcTrapOutOfBoundsIf(length > available, "parcByteArray_CopyOut %zd available bytes, %zd required", available, length); memcpy(array, &result->array[offset], length); return (PARCByteArray *) result; diff --git a/libparc/parc/algol/parc_ByteArray.h b/libparc/parc/algol/parc_ByteArray.h index 98cc970a..c7a26285 100644 --- a/libparc/parc/algol/parc_ByteArray.h +++ b/libparc/parc/algol/parc_ByteArray.h @@ -91,7 +91,7 @@ typedef struct parc_byte_array PARCByteArray; /** * Assert that an instance of `PARCByteArray` is valid. * - * If the instance is not valid, terminate via {@link trapIllegalValue} + * If the instance is not valid, terminate via {@link parcTrapIllegalValue} * * Valid means the internal state of the type is consistent with its required current or future behaviour. * This may include the validation of internal instances of types. @@ -331,7 +331,7 @@ int parcByteArray_Compare(const PARCByteArray *a, const PARCByteArray *b); * * @return The given `PARCByteArray` pointer * - * @throws SIGABRT `trapOutOfBounds` if the underlying `PARCByteArray` is not large enough + * @throws SIGABRT `parcTrapOutOfBounds` if the underlying `PARCByteArray` is not large enough * * Example: * @code diff --git a/libparc/parc/algol/parc_Deque.c b/libparc/parc/algol/parc_Deque.c index 4793b032..84808766 100644 --- a/libparc/parc/algol/parc_Deque.c +++ b/libparc/parc/algol/parc_Deque.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -104,27 +104,27 @@ _parcDequeNode_Destroy(PARCDeque *deque __attribute__((unused)), struct parc_deq static void _parcDequeNode_AssertInvariants(struct parc_deque_node *node) { - assertNotNull(node, "Expected non-null node pointer."); + parcAssertNotNull(node, "Expected non-null node pointer."); if (node->next != NULL) { - assertTrue(node->next->previous == node, "Expected next node to point to this node."); + parcAssertTrue(node->next->previous == node, "Expected next node to point to this node."); } if (node->previous != NULL) { - assertTrue(node->previous->next == node, "Expected previous node to point to this node."); + parcAssertTrue(node->previous->next == node, "Expected previous node to point to this node."); } } static void _parcDeque_AssertInvariants(const PARCDeque *deque) { - assertNotNull(deque, "Parameter cannot be null."); + parcAssertNotNull(deque, "Parameter cannot be null."); if (deque->head != NULL) { - assertTrue(deque->size != 0, "PARCDeque head is not-null, but size is zero."); - assertNotNull(deque->tail, "PARCDeque head is not-null, but tail is null."); + parcAssertTrue(deque->size != 0, "PARCDeque head is not-null, but size is zero."); + parcAssertNotNull(deque->tail, "PARCDeque head is not-null, but tail is null."); _parcDequeNode_AssertInvariants(deque->head); _parcDequeNode_AssertInvariants(deque->tail); } else { - assertNull(deque->tail, "PARCDeque head is null, but tail is not null."); - assertTrue(deque->size == 0, "PARCDeque head is null, but size is not zero."); + parcAssertNull(deque->tail, "PARCDeque head is null, but tail is not null."); + parcAssertTrue(deque->size == 0, "PARCDeque head is null, but size is not zero."); } } @@ -159,7 +159,7 @@ _parcDequeNode_Next(PARCDeque *deque __attribute__((unused)), const struct parc_ if (node == NULL) { return deque->head; } - trapOutOfBoundsIf(node->next == NULL, "No more elements."); + parcTrapOutOfBoundsIf(node->next == NULL, "No more elements."); return node->next; } @@ -386,7 +386,7 @@ void * parcDeque_GetAtIndex(const PARCDeque *deque, size_t index) { if (index > (parcDeque_Size(deque) - 1)) { - trapOutOfBounds(index, "[0, %zd]", parcDeque_Size(deque) - 1); + parcTrapOutOfBounds(index, "[0, %zd]", parcDeque_Size(deque) - 1); } struct parc_deque_node *node = deque->head; while (index--) { diff --git a/libparc/parc/algol/parc_Deque.h b/libparc/parc/algol/parc_Deque.h index 3e11e845..57dd39b1 100755 --- a/libparc/parc/algol/parc_Deque.h +++ b/libparc/parc/algol/parc_Deque.h @@ -282,7 +282,7 @@ bool parcDeque_IsEmpty(const PARCDeque *deque); * @param [in] deque A pointer to a `PARCDeque` instance. * @param [in] index The index of the element to be retrieved. * - * @throws `trapOutOfBounds` + * @throws `parcTrapOutOfBounds` * * Example: * @code diff --git a/libparc/parc/algol/parc_Dictionary.c b/libparc/parc/algol/parc_Dictionary.c index 628b08e2..a7a59de6 100755 --- a/libparc/parc/algol/parc_Dictionary.c +++ b/libparc/parc/algol/parc_Dictionary.c @@ -18,7 +18,7 @@ #include -#include +#include #include @@ -43,10 +43,10 @@ parcDictionary_Create(PARCDictionary_CompareKey keyCompareFunction, PARCDictionary_ValueEquals valueEqualsFunction, PARCDictionary_FreeValue valueFreeFunction) { - assertNotNull(keyCompareFunction, "KeyCompareFunction can't be null"); - assertNotNull(keyHashFunction, "KeyHashFunction can't be null"); + parcAssertNotNull(keyCompareFunction, "KeyCompareFunction can't be null"); + parcAssertNotNull(keyHashFunction, "KeyHashFunction can't be null"); PARCDictionary *dictionary = parcMemory_Allocate(sizeof(PARCDictionary)); - assertNotNull(dictionary, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCDictionary)); + parcAssertNotNull(dictionary, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCDictionary)); dictionary->keyCompareFunction = keyCompareFunction; dictionary->keyHashFunction = keyHashFunction; dictionary->keyFreeFunction = keyFreeFunction; @@ -65,8 +65,8 @@ parcDictionary_Create(PARCDictionary_CompareKey keyCompareFunction, void parcDictionary_Destroy(PARCDictionary **dictionaryPointer) { - assertNotNull(dictionaryPointer, "Pointer to dictionary pointer can't be NULL"); - assertNotNull(*dictionaryPointer, "Pointer to dictionary can't be NULL"); + parcAssertNotNull(dictionaryPointer, "Pointer to dictionary pointer can't be NULL"); + parcAssertNotNull(*dictionaryPointer, "Pointer to dictionary can't be NULL"); parcTreeRedBlack_Destroy(&((*dictionaryPointer)->tree)); parcMemory_Deallocate((void **) dictionaryPointer); *dictionaryPointer = NULL; @@ -75,60 +75,60 @@ parcDictionary_Destroy(PARCDictionary **dictionaryPointer) void parcDictionary_SetValue(PARCDictionary *dictionary, void *key, void *value) { - assertNotNull(dictionary, "dictionary pointer can't be NULL"); - assertNotNull(key, "Key pointer can't be NULL"); + parcAssertNotNull(dictionary, "dictionary pointer can't be NULL"); + parcAssertNotNull(key, "Key pointer can't be NULL"); parcTreeRedBlack_Insert(dictionary->tree, key, value); } void * parcDictionary_GetValue(PARCDictionary *dictionary, const void *key) { - assertNotNull(dictionary, "dictionary pointer can't be NULL"); - assertNotNull(key, "Key pointer can't be NULL"); + parcAssertNotNull(dictionary, "dictionary pointer can't be NULL"); + parcAssertNotNull(key, "Key pointer can't be NULL"); return parcTreeRedBlack_Get(dictionary->tree, key); } void * parcDictionary_RemoveValue(PARCDictionary *dictionary, const void *key) { - assertNotNull(dictionary, "dictionary pointer can't be NULL"); - assertNotNull(key, "Key pointer can't be NULL"); + parcAssertNotNull(dictionary, "dictionary pointer can't be NULL"); + parcAssertNotNull(key, "Key pointer can't be NULL"); return parcTreeRedBlack_Remove(dictionary->tree, key); } void parcDictionary_RemoveAndDestroyValue(PARCDictionary *dictionary, const void *key) { - assertNotNull(dictionary, "dictionary pointer can't be NULL"); - assertNotNull(key, "Key pointer can't be NULL"); + parcAssertNotNull(dictionary, "dictionary pointer can't be NULL"); + parcAssertNotNull(key, "Key pointer can't be NULL"); parcTreeRedBlack_RemoveAndDestroy(dictionary->tree, key); } PARCArrayList * parcDictionary_Keys(const PARCDictionary *dictionary) { - assertNotNull(dictionary, "dictionary pointer can't be NULL"); + parcAssertNotNull(dictionary, "dictionary pointer can't be NULL"); return parcTreeRedBlack_Keys(dictionary->tree); } PARCArrayList * parcDictionary_Values(const PARCDictionary *dictionary) { - assertNotNull(dictionary, "dictionary pointer can't be NULL"); + parcAssertNotNull(dictionary, "dictionary pointer can't be NULL"); return parcTreeRedBlack_Values(dictionary->tree); } size_t parcDictionary_Size(const PARCDictionary *dictionary) { - assertNotNull(dictionary, "dictionary pointer can't be NULL"); + parcAssertNotNull(dictionary, "dictionary pointer can't be NULL"); return parcTreeRedBlack_Size(dictionary->tree); } int parcDictionary_Equals(const PARCDictionary *dictionary1, const PARCDictionary *dictionary2) { - assertNotNull(dictionary1, "dictionary pointer can't be NULL"); - assertNotNull(dictionary2, "dictionary pointer can't be NULL"); + parcAssertNotNull(dictionary1, "dictionary pointer can't be NULL"); + parcAssertNotNull(dictionary2, "dictionary pointer can't be NULL"); return parcTreeRedBlack_Equals(dictionary1->tree, dictionary2->tree); } diff --git a/libparc/parc/algol/parc_DisplayIndented.c b/libparc/parc/algol/parc_DisplayIndented.c index 5e043c15..39e1d76e 100755 --- a/libparc/parc/algol/parc_DisplayIndented.c +++ b/libparc/parc/algol/parc_DisplayIndented.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -39,7 +39,7 @@ _indent(int indentation) if (indentation > 0) { result = write(1, _spaces, indentation * _indentationFactor); - assertTrue(result == (indentation * _indentationFactor), + parcAssertTrue(result == (indentation * _indentationFactor), "Write(2) failed to write %zd bytes.", indentation * _indentationFactor); } return result; @@ -55,11 +55,11 @@ _parcDisplayIndented_Print(int indentation, char *string) _indent(indentation); if (end != NULL) { ssize_t nwritten = write(1, start, end - start + 1); - assertTrue(nwritten >= 0, "Error calling write"); + parcAssertTrue(nwritten >= 0, "Error calling write"); start = end + 1; } else { ssize_t nwritten = write(1, start, strlen(start)); - assertTrue(nwritten >= 0, "Error calling write"); + parcAssertTrue(nwritten >= 0, "Error calling write"); break; } end = strchr(start, '\n'); @@ -74,14 +74,14 @@ parcDisplayIndented_PrintLine(int indentation, const char *format, ...) char *cString; int length = vasprintf(&cString, format, ap); - assertTrue(length >= 0, "Error in vasprintf"); + parcAssertTrue(length >= 0, "Error in vasprintf"); va_end(ap); _parcDisplayIndented_Print(indentation, cString); ssize_t nwritten = write(1, "\n", 1); - assertTrue(nwritten >= 0, "Error calling write"); + parcAssertTrue(nwritten >= 0, "Error calling write"); free(cString); } @@ -98,7 +98,7 @@ parcDisplayIndented_PrintMemory(int indentation, size_t length, const char memor char *cString; for (size_t offset = 0; offset < length; /**/) { int nwritten = asprintf(&cString, "%p=[", &memory[offset]); - assertTrue(nwritten >= 0, "Error calling asprintf"); + parcAssertTrue(nwritten >= 0, "Error calling asprintf"); _parcDisplayIndented_Print(indentation, cString); free(cString); diff --git a/libparc/parc/algol/parc_Event.c b/libparc/parc/algol/parc_Event.c index 0a8391aa..1621edac 100755 --- a/libparc/parc/algol/parc_Event.c +++ b/libparc/parc/algol/parc_Event.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include "internal_parc_Event.h" #include @@ -70,7 +70,7 @@ PARCEvent * parcEvent_Create(PARCEventScheduler *parcEventScheduler, int fd, PARCEventType flags, PARCEvent_Callback *callback, void *callbackArgs) { PARCEvent *parcEvent = parcMemory_Allocate(sizeof(PARCEvent)); - assertNotNull(parcEvent, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEvent)); + parcAssertNotNull(parcEvent, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEvent)); parcEvent->parcEventScheduler = parcEventScheduler; parcEvent->callback = callback; @@ -78,7 +78,7 @@ parcEvent_Create(PARCEventScheduler *parcEventScheduler, int fd, PARCEventType f parcEvent->event = event_new(parcEventScheduler_GetEvBase(parcEventScheduler), fd, internal_PARCEventType_to_libevent_type(flags), _parc_event_callback, parcEvent); - assertNotNull(parcEvent->event, "Could not create a new event!"); + parcAssertNotNull(parcEvent->event, "Could not create a new event!"); parcEvent_LogDebug(parcEvent, "parcEvent_Create(base=%p,fd=%x,events=%x,cb=%p,args=%p)\n", @@ -91,7 +91,7 @@ int parcEvent_Start(PARCEvent *parcEvent) { parcEvent_LogDebug(parcEvent, "parcEvent_Start(%p)\n", parcEvent); - assertNotNull(parcEvent, "parcEvent_Start must be passed a valid event!"); + parcAssertNotNull(parcEvent, "parcEvent_Start must be passed a valid event!"); int result = event_add(parcEvent->event, NULL); return result; @@ -101,7 +101,7 @@ int parcEvent_Stop(PARCEvent *parcEvent) { parcEvent_LogDebug(parcEvent, "parcEvent_Stop(%p)\n", parcEvent); - assertNotNull(parcEvent, "parcEvent_Stop must be passed a valid event!"); + parcAssertNotNull(parcEvent, "parcEvent_Stop must be passed a valid event!"); int result = event_del(parcEvent->event); return result; @@ -111,7 +111,7 @@ int parcEvent_Poll(PARCEvent *parcEvent, PARCEventType event) { parcEvent_LogDebug(parcEvent, "parcEvent_Stop(%p)\n", parcEvent); - assertNotNull(parcEvent, "parcEvent_Stop must be passed a valid event!"); + parcAssertNotNull(parcEvent, "parcEvent_Stop must be passed a valid event!"); int result = event_pending(parcEvent->event, event, NULL); return result; @@ -121,8 +121,8 @@ void parcEvent_Destroy(PARCEvent **parcEvent) { parcEvent_LogDebug((*parcEvent), "parcEvent_Destroy(%p)\n", *parcEvent); - assertNotNull(*parcEvent, "parcEvent_Destroy must be passed a valid parcEvent!"); - assertNotNull((*parcEvent)->event, "parcEvent_Destroy passed a null event!"); + parcAssertNotNull(*parcEvent, "parcEvent_Destroy must be passed a valid parcEvent!"); + parcAssertNotNull((*parcEvent)->event, "parcEvent_Destroy passed a null event!"); event_free((*parcEvent)->event); parcMemory_Deallocate((void **) parcEvent); diff --git a/libparc/parc/algol/parc_EventBuffer.c b/libparc/parc/algol/parc_EventBuffer.c index 49ba3354..6293680c 100644 --- a/libparc/parc/algol/parc_EventBuffer.c +++ b/libparc/parc/algol/parc_EventBuffer.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include "internal_parc_Event.h" #include @@ -55,10 +55,10 @@ parcEventBuffer_Create(void) { internal_parc_initializeLibevent(); struct evbuffer *new_evbuffer = evbuffer_new(); - assertNotNull(new_evbuffer, "libevent returned a null evbuffer.\n"); + parcAssertNotNull(new_evbuffer, "libevent returned a null evbuffer.\n"); PARCEventBuffer *parcEventBuffer = parcMemory_AllocateAndClear(sizeof(PARCEventBuffer)); - assertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer)); + parcAssertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer)); parcEventBuffer->allocated_evbuffer = new_evbuffer; parcEventBuffer->evbuffer = parcEventBuffer->allocated_evbuffer; @@ -71,8 +71,8 @@ void parcEventBuffer_Destroy(PARCEventBuffer **parcEventBuffer) { parcEventBuffer_LogDebug((*parcEventBuffer), "parcEventBuffer_Destroy(parcEventBuffer=%p)\n", *parcEventBuffer); - assertNotNull(parcEventBuffer, "parcEventBuffer_Destroy was passed a null parcEventBuffer pointer\n"); - assertNotNull(*parcEventBuffer, "parcEventBuffer_Destroy was passed a null parcEventBuffer\n"); + parcAssertNotNull(parcEventBuffer, "parcEventBuffer_Destroy was passed a null parcEventBuffer pointer\n"); + parcAssertNotNull(*parcEventBuffer, "parcEventBuffer_Destroy was passed a null parcEventBuffer\n"); // Destroy allocated eveventBuffer if it was allocated by us, otherwise it's owned by bufferevent if ((*parcEventBuffer)->allocated_evbuffer) { @@ -100,7 +100,7 @@ parcEventBuffer_IsValid(const PARCEventBuffer *eventBuffer) void parcEventBuffer_AssertValid(const PARCEventBuffer *eventBuffer) { - assertTrue(parcEventBuffer_IsValid(eventBuffer), + parcAssertTrue(parcEventBuffer_IsValid(eventBuffer), "PARCEventBuffer@%p is not valid.", (void *) eventBuffer); } @@ -109,7 +109,7 @@ parcEventBuffer_GetLength(PARCEventBuffer *parcEventBuffer) { parcEventBuffer_LogDebug(parcEventBuffer, "parcEventBuffer_GetLength(parcEventBuffer=%p)\n", parcEventBuffer); // parcEventBuffer_OptionalAssertValid(parcEventBuffer); - assertNotNull(parcEventBuffer, "parcEventBuffer_GetLength was passed a null parcEventBuffer\n"); + parcAssertNotNull(parcEventBuffer, "parcEventBuffer_GetLength was passed a null parcEventBuffer\n"); if (parcEventBuffer->evbuffer) { return evbuffer_get_length(parcEventBuffer->evbuffer); @@ -124,8 +124,8 @@ parcEventBuffer_Pullup(PARCEventBuffer *parcEventBuffer, ssize_t size) parcEventBuffer_LogDebug(parcEventBuffer, "parcEventBuffer_Pullup(parcEventBuffer=%p,size=%zx)\n", parcEventBuffer, size); parcEventBuffer_OptionalAssertValid(parcEventBuffer); -// assertNotNull(parcEventBuffer, "parcEventBuffer_Pullup was passed a null parcEventBuffer\n"); -// assertNotNull(parcEventBuffer->evbuffer, "parcEventBuffer_Pullup was passed a null libevent evbuffer\n"); +// parcAssertNotNull(parcEventBuffer, "parcEventBuffer_Pullup was passed a null parcEventBuffer\n"); +// parcAssertNotNull(parcEventBuffer->evbuffer, "parcEventBuffer_Pullup was passed a null libevent evbuffer\n"); return evbuffer_pullup(parcEventBuffer->evbuffer, (ev_ssize_t) size); } @@ -135,10 +135,10 @@ parcEventBuffer_ReadIntoBuffer(PARCEventBuffer *source, PARCEventBuffer *destina { parcEventBuffer_OptionalAssertValid(source); parcEventBuffer_OptionalAssertValid(destination); -// assertNotNull(source, "parcEventBuffer_ReadIntoBuffer was passed a null source buffer\n"); -// assertNotNull(source->evbuffer, "parcEventBuffer_ReadIntoBuffer was passed a null source evbuffer\n"); -// assertNotNull(destination, "parcEventBuffer_ReadIntoBuffer was passed a null destination buffer\n"); -// assertNotNull(destination->evbuffer, "parcEventBuffer_ReadIntoBuffer was passed a null destination evbuffer\n"); +// parcAssertNotNull(source, "parcEventBuffer_ReadIntoBuffer was passed a null source buffer\n"); +// parcAssertNotNull(source->evbuffer, "parcEventBuffer_ReadIntoBuffer was passed a null source evbuffer\n"); +// parcAssertNotNull(destination, "parcEventBuffer_ReadIntoBuffer was passed a null destination buffer\n"); +// parcAssertNotNull(destination->evbuffer, "parcEventBuffer_ReadIntoBuffer was passed a null destination evbuffer\n"); return evbuffer_remove_buffer(source->evbuffer, destination->evbuffer, length); } @@ -147,8 +147,8 @@ int parcEventBuffer_Read(PARCEventBuffer *readBuffer, void *data, size_t length) { parcEventBuffer_OptionalAssertValid(readBuffer); -// assertNotNull(readBuffer, "parcEventBuffer_Read was passed a null buffer\n"); -// assertNotNull(readBuffer->evbuffer, "parcEventBuffer_Read was passed a null libevent evbuffer\n"); +// parcAssertNotNull(readBuffer, "parcEventBuffer_Read was passed a null buffer\n"); +// parcAssertNotNull(readBuffer->evbuffer, "parcEventBuffer_Read was passed a null libevent evbuffer\n"); if (data == NULL) { return evbuffer_drain(readBuffer->evbuffer, length); @@ -160,7 +160,7 @@ parcEventBuffer_Read(PARCEventBuffer *readBuffer, void *data, size_t length) int parcEventBuffer_copyOut(PARCEventBuffer *readBuffer, void *data_out, size_t length) { - assertNotNull(data_out, "parcEventBuffer_Copy was passed a null data_out buffer\n"); + parcAssertNotNull(data_out, "parcEventBuffer_Copy was passed a null data_out buffer\n"); parcEventBuffer_OptionalAssertValid(readBuffer); return evbuffer_copyout(readBuffer->evbuffer, data_out, length); } @@ -170,8 +170,8 @@ parcEventBuffer_WriteToFileDescriptor(PARCEventBuffer *writeBuffer, int fd, ssiz { parcEventBuffer_OptionalAssertValid(writeBuffer); -// assertNotNull(writeBuffer, "parcEventBuffer_WriteToFileDescriptor was passed a null buffer\n"); -// assertNotNull(writeBuffer->evbuffer, "parcEventBuffer_WriteToFileDescriptor was passed a null libevent evbuffer\n"); +// parcAssertNotNull(writeBuffer, "parcEventBuffer_WriteToFileDescriptor was passed a null buffer\n"); +// parcAssertNotNull(writeBuffer->evbuffer, "parcEventBuffer_WriteToFileDescriptor was passed a null libevent evbuffer\n"); return evbuffer_write_atmost(writeBuffer->evbuffer, fd, length); } @@ -180,8 +180,8 @@ int parcEventBuffer_ReadFromFileDescriptor(PARCEventBuffer *readBuffer, int fd, size_t length) { parcEventBuffer_OptionalAssertValid(readBuffer); -// assertNotNull(readBuffer, "parcEventBuffer_ReadFromFileDescriptor was passed a null buffer\n"); -// assertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadFromFileDescriptor was passed a null libevent evbuffer\n"); +// parcAssertNotNull(readBuffer, "parcEventBuffer_ReadFromFileDescriptor was passed a null buffer\n"); +// parcAssertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadFromFileDescriptor was passed a null libevent evbuffer\n"); return evbuffer_read(readBuffer->evbuffer, fd, (int) length); } @@ -190,8 +190,8 @@ void parcEventBuffer_FreeLine(PARCEventBuffer *readBuffer, char **line) { parcEventBuffer_OptionalAssertValid(readBuffer); -// assertNotNull(readBuffer, "parcEventBuffer_ReadLine was passed a null readBuffer\n"); -// assertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadLine was passed a null libevent evbuffer\n"); +// parcAssertNotNull(readBuffer, "parcEventBuffer_ReadLine was passed a null readBuffer\n"); +// parcAssertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadLine was passed a null libevent evbuffer\n"); parcMemory_Deallocate((void **) line); } @@ -200,8 +200,8 @@ char * parcEventBuffer_ReadLine(PARCEventBuffer *readBuffer, size_t *length) { parcEventBuffer_OptionalAssertValid(readBuffer); -// assertNotNull(readBuffer, "parcEventBuffer_ReadLine was passed a null readBuffer\n"); -// assertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadLine was passed a null libevent evbuffer\n"); +// parcAssertNotNull(readBuffer, "parcEventBuffer_ReadLine was passed a null readBuffer\n"); +// parcAssertNotNull(readBuffer->evbuffer, "parcEventBuffer_ReadLine was passed a null libevent evbuffer\n"); return evbuffer_readln(readBuffer->evbuffer, length, EVBUFFER_EOL_CRLF); } @@ -211,10 +211,10 @@ parcEventBuffer_AppendBuffer(PARCEventBuffer *source, PARCEventBuffer *destinati { parcEventBuffer_OptionalAssertValid(source); parcEventBuffer_OptionalAssertValid(destination); -// assertNotNull(source, "parcEventBuffer_AppendBuffer was passed a null source parcEventBuffer\n"); -// assertNotNull(destination, "parcEventBuffer_AppendBuffer was passed a null destination parcEventBuffer\n"); -// assertNotNull(source->evbuffer, "parcEventBuffer_AppendBuffer was passed a null source libevent evbuffer\n"); -// assertNotNull(destination->evbuffer, "parcEventBuffer_AppendBuffer was passed a null destination libevent evbuffer\n"); +// parcAssertNotNull(source, "parcEventBuffer_AppendBuffer was passed a null source parcEventBuffer\n"); +// parcAssertNotNull(destination, "parcEventBuffer_AppendBuffer was passed a null destination parcEventBuffer\n"); +// parcAssertNotNull(source->evbuffer, "parcEventBuffer_AppendBuffer was passed a null source libevent evbuffer\n"); +// parcAssertNotNull(destination->evbuffer, "parcEventBuffer_AppendBuffer was passed a null destination libevent evbuffer\n"); return evbuffer_add_buffer(destination->evbuffer, source->evbuffer); } @@ -223,9 +223,9 @@ int parcEventBuffer_Append(PARCEventBuffer *parcEventBuffer, void *data, size_t length) { parcEventBuffer_OptionalAssertValid(parcEventBuffer); -// assertNotNull(parcEventBuffer, "parcEventBuffer_Append was passed a null parcEventBuffer\n"); -// assertNotNull(parcEventBuffer->evbuffer, "parcEventBuffer_Append was passed a null libevent evbuffer\n"); - assertNotNull(data, "parcEventBuffer_Append was passed a null data buffer\n"); +// parcAssertNotNull(parcEventBuffer, "parcEventBuffer_Append was passed a null parcEventBuffer\n"); +// parcAssertNotNull(parcEventBuffer->evbuffer, "parcEventBuffer_Append was passed a null libevent evbuffer\n"); + parcAssertNotNull(data, "parcEventBuffer_Append was passed a null data buffer\n"); return evbuffer_add(parcEventBuffer->evbuffer, data, length); } @@ -234,9 +234,9 @@ int parcEventBuffer_Prepend(PARCEventBuffer *readBuffer, void *data, size_t length) { parcEventBuffer_OptionalAssertValid(readBuffer); -// assertNotNull(readBuffer->evbuffer, "parcEventBuffer_Prepend was passed a null libevent evbuffer\n"); -// assertNotNull(readBuffer, "parcEventBuffer_Prepend was passed a null buffer\n"); - assertNotNull(data, "parcEventBuffer_Prepend was passed a null data buffer\n"); +// parcAssertNotNull(readBuffer->evbuffer, "parcEventBuffer_Prepend was passed a null libevent evbuffer\n"); +// parcAssertNotNull(readBuffer, "parcEventBuffer_Prepend was passed a null buffer\n"); + parcAssertNotNull(data, "parcEventBuffer_Prepend was passed a null data buffer\n"); return evbuffer_prepend(readBuffer->evbuffer, data, length); } @@ -244,10 +244,10 @@ parcEventBuffer_Prepend(PARCEventBuffer *readBuffer, void *data, size_t length) PARCEventBuffer * parcEventBuffer_GetQueueBufferInput(PARCEventQueue *queue) { - assertNotNull(queue, "parcEventBuffer_GetQueueBufferInput was passed a null queue\n"); + parcAssertNotNull(queue, "parcEventBuffer_GetQueueBufferInput was passed a null queue\n"); PARCEventBuffer *parcEventBuffer = parcMemory_AllocateAndClear(sizeof(PARCEventBuffer)); - assertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer)); + parcAssertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer)); parcEventBuffer->evbuffer = internal_parcEventQueue_GetEvInputBuffer(queue); parcEventBuffer_LogDebug(parcEventBuffer, "parcEventBuffer_GetQueueBufferInput(queue=%p)\n", queue); @@ -258,10 +258,10 @@ parcEventBuffer_GetQueueBufferInput(PARCEventQueue *queue) PARCEventBuffer * parcEventBuffer_GetQueueBufferOutput(PARCEventQueue *queue) { - assertNotNull(queue, "parcEventBuffer_GetQueueBufferOutput was passed a null queue\n"); + parcAssertNotNull(queue, "parcEventBuffer_GetQueueBufferOutput was passed a null queue\n"); PARCEventBuffer *parcEventBuffer = parcMemory_AllocateAndClear(sizeof(PARCEventBuffer)); - assertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer)); + parcAssertNotNull(parcEventBuffer, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventBuffer)); parcEventBuffer->evbuffer = internal_parcEventQueue_GetEvOutputBuffer(queue); parcEventBuffer_LogDebug(parcEventBuffer, "parcEventBuffer_GetQueueBufferInput(queue=%p)\n", queue); diff --git a/libparc/parc/algol/parc_EventQueue.c b/libparc/parc/algol/parc_EventQueue.c index 5d656a12..dffab1e7 100755 --- a/libparc/parc/algol/parc_EventQueue.c +++ b/libparc/parc/algol/parc_EventQueue.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include "internal_parc_Event.h" #include @@ -70,7 +70,7 @@ _parc_queue_read_callback(struct bufferevent *bev, void *ptr) parcEventQueue_LogDebug(parcEventQueue, "_parc_queue_read_callback(bev=%p,ptr->buffereventBuffer=%p,parcEventQueue=%p)\n", bev, parcEventQueue->buffereventBuffer, parcEventQueue); - assertNotNull(parcEventQueue->readCallback, "parcEvent read callback called when NULL"); + parcAssertNotNull(parcEventQueue->readCallback, "parcEvent read callback called when NULL"); parcEventQueue->readCallback(parcEventQueue, PARCEventType_Read, parcEventQueue->readUserData); } @@ -82,7 +82,7 @@ _parc_queue_write_callback(struct bufferevent *bev, void *ptr) parcEventQueue_LogDebug(parcEventQueue, "_parc_queue_write_callback(bev=%p,ptr->buffereventBuffer=%p,parcEventQueue=%p)\n", bev, parcEventQueue->buffereventBuffer, parcEventQueue); - assertNotNull(parcEventQueue->writeCallback, "parcEvent write callback called when NULL"); + parcAssertNotNull(parcEventQueue->writeCallback, "parcEvent write callback called when NULL"); parcEventQueue->writeCallback(parcEventQueue, PARCEventType_Write, parcEventQueue->writeUserData); } @@ -95,7 +95,7 @@ _parc_queue_event_callback(struct bufferevent *bev, short events, void *ptr) parcEventQueue_LogDebug(parcEventQueue, "_parc_queue_event_callback(bev=%p,events=%x,errno=%d,ptr->buffereventBuffer=%p,parcEventQueue=%p)\n", bev, events, errno, parcEventQueue->buffereventBuffer, parcEventQueue); - assertNotNull(parcEventQueue->eventCallback, "parcEvent event callback called when NULL"); + parcAssertNotNull(parcEventQueue->eventCallback, "parcEvent event callback called when NULL"); errno = errno_forwarded; parcEventQueue->eventCallback(parcEventQueue, internal_bufferevent_type_to_PARCEventQueueEventType(events), parcEventQueue->eventUserData); @@ -130,9 +130,9 @@ parcEventQueue_SetCallbacks(PARCEventQueue *parcEventQueue, PARCEventQueue * parcEventQueue_Create(PARCEventScheduler *eventScheduler, int fd, PARCEventQueueOption flags) { - assertNotNull(eventScheduler, "parcEventQueue_Create passed a NULL scheduler instance."); + parcAssertNotNull(eventScheduler, "parcEventQueue_Create passed a NULL scheduler instance."); PARCEventQueue *parcEventQueue = parcMemory_AllocateAndClear(sizeof(PARCEventQueue)); - assertNotNull(parcEventQueue, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue)); + parcAssertNotNull(parcEventQueue, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue)); parcEventQueue->eventScheduler = eventScheduler; // @@ -145,7 +145,7 @@ parcEventQueue_Create(PARCEventScheduler *eventScheduler, int fd, PARCEventQueue // parcEventQueue->buffereventBuffer = bufferevent_socket_new(parcEventScheduler_GetEvBase(eventScheduler), fd, internal_PARCEventQueueOption_to_bufferevent_options(flags)); - assertNotNull(parcEventQueue->buffereventBuffer, + parcAssertNotNull(parcEventQueue->buffereventBuffer, "Got null from bufferevent_socket_new for socket %d", fd); parcEventQueue_LogDebug(parcEventQueue, @@ -161,7 +161,7 @@ void parcEventQueue_Destroy(PARCEventQueue **parcEventQueue) { parcEventQueue_LogDebug((*parcEventQueue), "parcEventQueue_Destroy(ptr=%p)\n", *parcEventQueue); - assertNotNull((*parcEventQueue)->buffereventBuffer, "parcEventQueue_Destroy passed a null buffer!"); + parcAssertNotNull((*parcEventQueue)->buffereventBuffer, "parcEventQueue_Destroy passed a null buffer!"); bufferevent_free((*parcEventQueue)->buffereventBuffer); parcMemory_Deallocate((void *) parcEventQueue); @@ -226,7 +226,7 @@ int parcEventQueue_Printf(PARCEventQueue *parcEventQueue, const char *fmt, ...) { struct evbuffer *buffer = bufferevent_get_output(parcEventQueue->buffereventBuffer); - assertNotNull(buffer, "bufferevent_get_output returned NULL"); + parcAssertNotNull(buffer, "bufferevent_get_output returned NULL"); va_list ap; @@ -258,9 +258,9 @@ parcEventQueue_SetPriority(PARCEventQueue *eventQueue, PARCEventPriority priorit PARCEventQueuePair * parcEventQueue_CreateConnectedPair(PARCEventScheduler *eventScheduler) { - assertNotNull(eventScheduler, "parcEventQueue_CreateConnectedPair must be passed a valid Event Scheduler"); + parcAssertNotNull(eventScheduler, "parcEventQueue_CreateConnectedPair must be passed a valid Event Scheduler"); PARCEventQueuePair *parcEventQueuePair = parcMemory_AllocateAndClear(sizeof(PARCEventQueuePair)); - assertNotNull(parcEventQueuePair, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueuePair)); + parcAssertNotNull(parcEventQueuePair, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueuePair)); parcEventQueuePair->up = parcMemory_AllocateAndClear(sizeof(PARCEventQueue)); parcEventQueuePair->up->eventScheduler = eventScheduler; @@ -269,7 +269,7 @@ parcEventQueue_CreateConnectedPair(PARCEventScheduler *eventScheduler) eventScheduler, parcEventScheduler_GetEvBase(eventScheduler), parcEventQueuePair->up); - assertNotNull(parcEventQueuePair->up, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue)); + parcAssertNotNull(parcEventQueuePair->up, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue)); parcEventQueuePair->down = parcMemory_AllocateAndClear(sizeof(PARCEventQueue)); parcEventQueuePair->down->eventScheduler = eventScheduler; @@ -278,7 +278,7 @@ parcEventQueue_CreateConnectedPair(PARCEventScheduler *eventScheduler) eventScheduler, parcEventScheduler_GetEvBase(eventScheduler), parcEventQueuePair->down); - assertNotNull(parcEventQueuePair->down, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue)); + parcAssertNotNull(parcEventQueuePair->down, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCEventQueue)); struct bufferevent *evpair[2]; int result = bufferevent_pair_new(parcEventScheduler_GetEvBase(eventScheduler), 0, evpair); diff --git a/libparc/parc/algol/parc_EventScheduler.c b/libparc/parc/algol/parc_EventScheduler.c index 55de5c52..3983740e 100755 --- a/libparc/parc/algol/parc_EventScheduler.c +++ b/libparc/parc/algol/parc_EventScheduler.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -76,17 +76,17 @@ parcEventScheduler_Create(void) internal_parc_initializeLibevent(); PARCEventScheduler *parcEventScheduler = parcMemory_Allocate(sizeof(PARCEventScheduler)); - assertNotNull(parcEventScheduler, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventScheduler)); + parcAssertNotNull(parcEventScheduler, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventScheduler)); // Initialize libevent base pointer. parcEventScheduler->evbase = event_base_new(); - assertNotNull(parcEventScheduler->evbase, "Could not obtain an event base!"); + parcAssertNotNull(parcEventScheduler->evbase, "Could not obtain an event base!"); int result = event_base_priority_init(parcEventScheduler->evbase, PARCEventPriority_NumberOfPriorities); - assertTrue(result == 0, "Could not set scheduler priorities (%d)", result); + parcAssertTrue(result == 0, "Could not set scheduler priorities (%d)", result); parcEventScheduler->log = _parc_logger_create(); - assertNotNull(parcEventScheduler->log, "Could not create parc logger"); + parcAssertNotNull(parcEventScheduler->log, "Could not create parc logger"); parcEventScheduler_LogDebug(parcEventScheduler, "parcEventScheduler_Create() = %p\n", parcEventScheduler); @@ -97,7 +97,7 @@ int parcEventScheduler_Start(PARCEventScheduler *parcEventScheduler, PARCEventSchedulerDispatchType type) { parcEventScheduler_LogDebug(parcEventScheduler, "parcEventScheduler_Start(%p, %d)\n", parcEventScheduler, type); - assertNotNull(parcEventScheduler, "parcEventScheduler_Start must be passed a valid base parcEventScheduler!"); + parcAssertNotNull(parcEventScheduler, "parcEventScheduler_Start must be passed a valid base parcEventScheduler!"); int result = event_base_loop(parcEventScheduler->evbase, internal_PARCEventSchedulerDispatchType_to_eventloop_options(type)); return result; @@ -119,7 +119,7 @@ int parcEventScheduler_Stop(PARCEventScheduler *parcEventScheduler, struct timeval *delay) { parcEventScheduler_LogDebug(parcEventScheduler, "parcEventScheduler_Stop(%p, %p)\n", parcEventScheduler, delay); - assertNotNull(parcEventScheduler, "parcEventScheduler_Stop must be passed a valid base parcEventScheduler!"); + parcAssertNotNull(parcEventScheduler, "parcEventScheduler_Stop must be passed a valid base parcEventScheduler!"); int result = event_base_loopexit(parcEventScheduler->evbase, delay); return result; } @@ -128,7 +128,7 @@ int parcEventScheduler_Abort(PARCEventScheduler *parcEventScheduler) { parcEventScheduler_LogDebug(parcEventScheduler, "parcEventScheduler_Abort(%p)\n", parcEventScheduler); - assertNotNull(parcEventScheduler, "parcEventScheduler_Abort must be passed a valid base parcEventScheduler!"); + parcAssertNotNull(parcEventScheduler, "parcEventScheduler_Abort must be passed a valid base parcEventScheduler!"); int result = event_base_loopbreak(parcEventScheduler->evbase); return result; } @@ -156,8 +156,8 @@ parcEventScheduler_Destroy(PARCEventScheduler **parcEventScheduler) { parcEventScheduler_LogDebug((*parcEventScheduler), "parcEventScheduler_Destroy(%p)\n", *parcEventScheduler); - assertNotNull(*parcEventScheduler, "parcEventScheduler_Destroy must be passed a valid base parcEventScheduler!"); - assertNotNull((*parcEventScheduler)->evbase, "parcEventScheduler_Destroy passed a NULL event base member!"); + parcAssertNotNull(*parcEventScheduler, "parcEventScheduler_Destroy must be passed a valid base parcEventScheduler!"); + parcAssertNotNull((*parcEventScheduler)->evbase, "parcEventScheduler_Destroy passed a NULL event base member!"); event_base_free((*parcEventScheduler)->evbase); parcLog_Release(&((*parcEventScheduler)->log)); diff --git a/libparc/parc/algol/parc_EventSignal.c b/libparc/parc/algol/parc_EventSignal.c index 7b8d1191..7bb094bd 100755 --- a/libparc/parc/algol/parc_EventSignal.c +++ b/libparc/parc/algol/parc_EventSignal.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include "internal_parc_Event.h" #include @@ -66,7 +66,7 @@ PARCEventSignal * parcEventSignal_Create(PARCEventScheduler *eventScheduler, int signal, PARCEventType flags, PARCEvent_Callback *callback, void *callbackArgs) { PARCEventSignal *parcEventSignal = parcMemory_Allocate(sizeof(PARCEventSignal)); - assertNotNull(parcEventSignal, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventSignal)); + parcAssertNotNull(parcEventSignal, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventSignal)); parcEventSignal->eventScheduler = eventScheduler; parcEventSignal->callback = callback; @@ -75,7 +75,7 @@ parcEventSignal_Create(PARCEventScheduler *eventScheduler, int signal, PARCEvent parcEventSignal->event = event_new(parcEventScheduler_GetEvBase(eventScheduler), signal, internal_PARCEventType_to_libevent_type(flags), _parc_event_signal_callback, parcEventSignal); - assertNotNull(parcEventSignal->event, "Could not create a new event!"); + parcAssertNotNull(parcEventSignal->event, "Could not create a new event!"); parcEventSignal_LogDebug(parcEventSignal, "parcEventSignal_Create(base=%p,signal=%x,flags=%x,cb=%p,args=%p) = %p\n", @@ -88,7 +88,7 @@ int parcEventSignal_Start(PARCEventSignal *parcEventSignal) { parcEventSignal_LogDebug(parcEventSignal, "parcEventSignal_Start(event=%p)\n", parcEventSignal); - assertNotNull(parcEventSignal, "parcEventStart_Signal must be passed a valid event!"); + parcAssertNotNull(parcEventSignal, "parcEventStart_Signal must be passed a valid event!"); int result = event_add(parcEventSignal->event, NULL); return result; @@ -98,7 +98,7 @@ int parcEventSignal_Stop(PARCEventSignal *parcEventSignal) { parcEventSignal_LogDebug(parcEventSignal, "parcEventSignal_Stop(event=%p)\n", parcEventSignal); - assertNotNull(parcEventSignal, "parcEvent_Stop must be passed a valid event!"); + parcAssertNotNull(parcEventSignal, "parcEvent_Stop must be passed a valid event!"); int result = event_del(parcEventSignal->event); return result; @@ -108,8 +108,8 @@ void parcEventSignal_Destroy(PARCEventSignal **parcEventSignal) { parcEventSignal_LogDebug((*parcEventSignal), "parcEventSignal_Destroy(event=%p)\n", parcEventSignal); - assertNotNull(*parcEventSignal, "parcEvent_Destroy must be passed a valid parcEventSignal!"); - assertNotNull((*parcEventSignal)->event, "parcEvent_Destroy passed a null event!"); + parcAssertNotNull(*parcEventSignal, "parcEvent_Destroy must be passed a valid parcEventSignal!"); + parcAssertNotNull((*parcEventSignal)->event, "parcEvent_Destroy passed a null event!"); event_free((*parcEventSignal)->event); parcMemory_Deallocate((void **) parcEventSignal); } diff --git a/libparc/parc/algol/parc_EventSocket.c b/libparc/parc/algol/parc_EventSocket.c index dcb2fd69..62aa10bc 100755 --- a/libparc/parc/algol/parc_EventSocket.c +++ b/libparc/parc/algol/parc_EventSocket.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -87,7 +87,7 @@ parcEventSocket_Create(PARCEventScheduler *eventScheduler, void *userData, const struct sockaddr *sa, int socklen) { PARCEventSocket *parcEventSocket = parcMemory_AllocateAndClear(sizeof(PARCEventSocket)); - assertNotNull(parcEventSocket, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventSocket)); + parcAssertNotNull(parcEventSocket, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventSocket)); parcEventSocket->eventScheduler = eventScheduler; parcEventSocket->socketCallback = callback; @@ -118,7 +118,7 @@ parcEventSocket_Create(PARCEventScheduler *eventScheduler, void parcEventSocket_Destroy(PARCEventSocket **socketEvent) { - assertNotNull(*socketEvent, "parcEventSocket_Destroy must be passed a valid socketEvent!"); + parcAssertNotNull(*socketEvent, "parcEventSocket_Destroy must be passed a valid socketEvent!"); if ((*socketEvent)->listener) { evconnlistener_free((*socketEvent)->listener); diff --git a/libparc/parc/algol/parc_EventTimer.c b/libparc/parc/algol/parc_EventTimer.c index 529188b1..82f731b1 100755 --- a/libparc/parc/algol/parc_EventTimer.c +++ b/libparc/parc/algol/parc_EventTimer.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include "internal_parc_Event.h" #include @@ -62,7 +62,7 @@ PARCEventTimer * parcEventTimer_Create(PARCEventScheduler *eventScheduler, PARCEventType flags, PARCEvent_Callback *callback, void *callbackArgs) { PARCEventTimer *parcEventTimer = parcMemory_Allocate(sizeof(PARCEventTimer)); - assertNotNull(parcEventTimer, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventTimer)); + parcAssertNotNull(parcEventTimer, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCEventTimer)); parcEventTimer->eventScheduler = eventScheduler; parcEventTimer->callback = callback; @@ -72,7 +72,7 @@ parcEventTimer_Create(PARCEventScheduler *eventScheduler, PARCEventType flags, P parcEventTimer->event = event_new(parcEventScheduler_GetEvBase(eventScheduler), -1, internal_PARCEventType_to_libevent_type(flags), _parc_event_timer_callback, parcEventTimer); - assertNotNull(parcEventTimer->event, "Could not create a new event!"); + parcAssertNotNull(parcEventTimer->event, "Could not create a new event!"); parcEventTimer_LogDebug(parcEventTimer, "parcEventTimer_Create(base=%p,events=%x,cb=%p,args=%p) = %p\n", @@ -88,7 +88,7 @@ parcEventTimer_Start(PARCEventTimer *parcEventTimer, struct timeval *timeout) parcEventTimer_LogDebug(parcEventTimer, "parcEventTimer_Start(event=%p, timeout=%d:%d)\n", parcEventTimer, timeout->tv_sec, timeout->tv_usec); - assertNotNull(parcEventTimer, "parcEventTimer_Start must be passed a valid event!"); + parcAssertNotNull(parcEventTimer, "parcEventTimer_Start must be passed a valid event!"); int result = event_add(parcEventTimer->event, timeout); return result; @@ -98,7 +98,7 @@ int parcEventTimer_Stop(PARCEventTimer *parcEventTimer) { parcEventTimer_LogDebug(parcEventTimer, "parcEventTimer_Stop(event=%p)\n", parcEventTimer); - assertNotNull(parcEventTimer, "parcEventTimer_Stop must be passed a valid event!"); + parcAssertNotNull(parcEventTimer, "parcEventTimer_Stop must be passed a valid event!"); int result = event_del(parcEventTimer->event); return result; @@ -108,8 +108,8 @@ void parcEventTimer_Destroy(PARCEventTimer **parcEventTimer) { parcEventTimer_LogDebug((*parcEventTimer), "parcEventTimer_Destroy(parcEventTimer=%p)\n", *parcEventTimer); - assertNotNull(*parcEventTimer, "parcEventTimer_Destroy must be passed a valid parcEventTimer!"); - assertNotNull((*parcEventTimer)->event, "parcEventTimer_Destroy passed a null event!"); + parcAssertNotNull(*parcEventTimer, "parcEventTimer_Destroy must be passed a valid parcEventTimer!"); + parcAssertNotNull((*parcEventTimer)->event, "parcEventTimer_Destroy passed a null event!"); event_free((*parcEventTimer)->event); parcMemory_Deallocate((void **) parcEventTimer); diff --git a/libparc/parc/algol/parc_File.c b/libparc/parc/algol/parc_File.c index 2ab307a2..353ffcca 100644 --- a/libparc/parc/algol/parc_File.c +++ b/libparc/parc/algol/parc_File.c @@ -37,7 +37,7 @@ #include #include -#include +#include #include #include @@ -66,8 +66,8 @@ parcObject_Override(PARCFile, PARCObject, void parcFile_AssertValid(const PARCFile *instance) { - trapIllegalValueIf(instance == NULL, "Parameter must be a non-null pointer to a valid PARCFile."); - trapIllegalValueIf(instance->pathName == NULL, "PARCFile cannot have a NULL path-name"); + parcTrapIllegalValueIf(instance == NULL, "Parameter must be a non-null pointer to a valid PARCFile."); + parcTrapIllegalValueIf(instance->pathName == NULL, "PARCFile cannot have a NULL path-name"); } PARCFile * @@ -194,10 +194,10 @@ parcFile_Delete(const PARCFile *file) char *string = parcPathName_ToString(file->pathName); // only allow under tmp - assertTrue(strncmp(string, "/tmp/", 5) == 0, + parcAssertTrue(strncmp(string, "/tmp/", 5) == 0, "Path must begin with /tmp/: %s", string); // dont allow ".." - assertNull(strstr(string, ".."), "Path cannot have .. in it: %s", string); + parcAssertNull(strstr(string, ".."), "Path cannot have .. in it: %s", string); bool result = false; if (parcFile_IsDirectory(file)) { @@ -208,7 +208,7 @@ parcFile_Delete(const PARCFile *file) int maximumFileDescriptors = 20; int failure = nftw(string, _deleteNode, maximumFileDescriptors, flags); - assertFalse(failure, "Error on recursive delete: (%d) %s", errno, strerror(errno)); + parcAssertFalse(failure, "Error on recursive delete: (%d) %s", errno, strerror(errno)); result = failure == false; } else { diff --git a/libparc/parc/algol/parc_FileInputStream.c b/libparc/parc/algol/parc_FileInputStream.c index f42ced73..186d07b5 100755 --- a/libparc/parc/algol/parc_FileInputStream.c +++ b/libparc/parc/algol/parc_FileInputStream.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -70,7 +70,7 @@ parcFileInputStream_Open(const PARCFile *file) PARCFileInputStream * parcFileInputStream_Create(int fileDescriptor) { - trapIllegalValueIf(fileDescriptor < 0, "File descriptor must not be negative."); + parcTrapIllegalValueIf(fileDescriptor < 0, "File descriptor must not be negative."); PARCFileInputStream *result = parcObject_CreateInstance(PARCFileInputStream); if (result != NULL) { diff --git a/libparc/parc/algol/parc_FileInputStream.h b/libparc/parc/algol/parc_FileInputStream.h index 3641e08a..f7f7987a 100755 --- a/libparc/parc/algol/parc_FileInputStream.h +++ b/libparc/parc/algol/parc_FileInputStream.h @@ -140,7 +140,7 @@ void parcFileInputStream_Release(PARCFileInputStream **inputStreamPtr); * * parcFileOutputStream_Write(stream, buffer); * - * assertFalse(parcBuffer_HasRemaining(buffer), "Expected the buffer to be emtpy"); + * parcAssertFalse(parcBuffer_HasRemaining(buffer), "Expected the buffer to be emtpy"); * * parcBuffer_Release(&buffer); * diff --git a/libparc/parc/algol/parc_FileOutputStream.c b/libparc/parc/algol/parc_FileOutputStream.c index a17dc66c..3e5c8cd6 100755 --- a/libparc/parc/algol/parc_FileOutputStream.c +++ b/libparc/parc/algol/parc_FileOutputStream.c @@ -20,7 +20,7 @@ #include #include -#include +#include #include #include @@ -48,7 +48,7 @@ parcObject_ExtendPARCObject(PARCFileOutputStream, _destroy, NULL, NULL, NULL, NU PARCFileOutputStream * parcFileOutputStream_Create(int fileDescriptor) { - assertTrue(fileDescriptor != -1, "Invalid file descriptor"); + parcAssertTrue(fileDescriptor != -1, "Invalid file descriptor"); PARCFileOutputStream *result = parcObject_CreateInstance(PARCFileOutputStream); result->fd = fileDescriptor; diff --git a/libparc/parc/algol/parc_FileOutputStream.h b/libparc/parc/algol/parc_FileOutputStream.h index 51251561..a9708b0d 100644 --- a/libparc/parc/algol/parc_FileOutputStream.h +++ b/libparc/parc/algol/parc_FileOutputStream.h @@ -130,7 +130,7 @@ void parcFileOutputStream_Release(PARCFileOutputStream **streamPtr); * * parcFileOutputStream_Write(stream, buffer); * - * assertFalse(parcBuffer_HasRemaining(buffer), "Expected the buffer to be emtpy"); + * parcAssertFalse(parcBuffer_HasRemaining(buffer), "Expected the buffer to be emtpy"); * * parcBuffer_Release(&buffer); * diff --git a/libparc/parc/algol/parc_HashCodeTable.c b/libparc/parc/algol/parc_HashCodeTable.c index ea1945b3..9531e312 100755 --- a/libparc/parc/algol/parc_HashCodeTable.c +++ b/libparc/parc/algol/parc_HashCodeTable.c @@ -28,7 +28,7 @@ */ #include -#include +#include #include #include @@ -181,7 +181,7 @@ _expand(PARCHashCodeTable *hashCodeTable) temp_table.tableLimit = old_table->tableLimit * expandby; temp_table.expandThreshold = temp_table.tableLimit - temp_table.tableLimit / 4; temp_table.entries = parcMemory_AllocateAndClear(temp_table.tableLimit * sizeof(HashTableEntry)); - assertNotNull(temp_table.entries, "parcMemory_AllocateAndClear(%zu) returned NULL", temp_table.tableLimit * sizeof(HashTableEntry)); + parcAssertNotNull(temp_table.entries, "parcMemory_AllocateAndClear(%zu) returned NULL", temp_table.tableLimit * sizeof(HashTableEntry)); result = _rehash(old_table, &temp_table, hashCodeTable->keyEqualsFunc); if (result == ADD_NOSPACE) { @@ -203,11 +203,11 @@ parcHashCodeTable_Create_Size(PARCHashCodeTable_KeyEqualsFunc keyEqualsFunc, size_t minimumSize) { PARCHashCodeTable *table = parcMemory_AllocateAndClear(sizeof(PARCHashCodeTable)); - assertNotNull(table, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCHashCodeTable)); + parcAssertNotNull(table, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCHashCodeTable)); - assertNotNull(keyEqualsFunc, "keyEqualsFunc must be non-null"); - assertNotNull(keyHashCodeFunc, "keyHashCodeFunc must be non-null"); - assertTrue(minimumSize > 0, "minimumSize must be greater than zero"); + parcAssertNotNull(keyEqualsFunc, "keyEqualsFunc must be non-null"); + parcAssertNotNull(keyHashCodeFunc, "keyHashCodeFunc must be non-null"); + parcAssertTrue(minimumSize > 0, "minimumSize must be greater than zero"); table->keyEqualsFunc = keyEqualsFunc; table->keyHashCodeFunc = keyHashCodeFunc; @@ -215,7 +215,7 @@ parcHashCodeTable_Create_Size(PARCHashCodeTable_KeyEqualsFunc keyEqualsFunc, table->dataDestroyer = dataDestroyer; table->hashtable.entries = parcMemory_AllocateAndClear(minimumSize * sizeof(HashTableEntry)); - assertNotNull(table->hashtable.entries, "parcMemory_AllocateAndClear(%zu) returned NULL", minimumSize * sizeof(HashTableEntry)); + parcAssertNotNull(table->hashtable.entries, "parcMemory_AllocateAndClear(%zu) returned NULL", minimumSize * sizeof(HashTableEntry)); table->hashtable.tableLimit = minimumSize; table->hashtable.tableSize = 0; @@ -239,8 +239,8 @@ parcHashCodeTable_Create(PARCHashCodeTable_KeyEqualsFunc keyEqualsFunc, void parcHashCodeTable_Destroy(PARCHashCodeTable **tablePtr) { - assertNotNull(tablePtr, "Parameter must be non-null double pointer"); - assertNotNull(*tablePtr, "Parameter must dereference to non-null pointer"); + parcAssertNotNull(tablePtr, "Parameter must be non-null double pointer"); + parcAssertNotNull(*tablePtr, "Parameter must dereference to non-null pointer"); PARCHashCodeTable *table = *tablePtr; size_t i; @@ -264,9 +264,9 @@ parcHashCodeTable_Destroy(PARCHashCodeTable **tablePtr) bool parcHashCodeTable_Add(PARCHashCodeTable *table, void *key, void *data) { - assertNotNull(table, "Parameter table must be non-null"); - assertNotNull(key, "Parameter key must be non-null"); - assertNotNull(data, "Parameter data must be non-null"); + parcAssertNotNull(table, "Parameter table must be non-null"); + parcAssertNotNull(key, "Parameter key must be non-null"); + parcAssertNotNull(data, "Parameter data must be non-null"); if (table->hashtable.tableSize >= table->hashtable.expandThreshold) { _expand(table); @@ -291,13 +291,13 @@ parcHashCodeTable_Del(PARCHashCodeTable *table, const void *key) size_t index; bool found; - assertNotNull(table, "Parameter table must be non-null"); - assertNotNull(key, "parameter key must be non-null"); + parcAssertNotNull(table, "Parameter table must be non-null"); + parcAssertNotNull(key, "parameter key must be non-null"); found = _findIndex(table, key, &index); if (found) { - assertTrue(table->hashtable.tableSize > 0, "Illegal state: found entry in a hash table with 0 size"); + parcAssertTrue(table->hashtable.tableSize > 0, "Illegal state: found entry in a hash table with 0 size"); if (table->keyDestroyer) { table->keyDestroyer(&table->hashtable.entries[index].key); @@ -318,8 +318,8 @@ parcHashCodeTable_Get(PARCHashCodeTable *table, const void *key) { size_t index; - assertNotNull(table, "Parameter table must be non-null"); - assertNotNull(key, "parameter key must be non-null"); + parcAssertNotNull(table, "Parameter table must be non-null"); + parcAssertNotNull(key, "parameter key must be non-null"); bool found = _findIndex(table, key, &index); @@ -333,6 +333,6 @@ parcHashCodeTable_Get(PARCHashCodeTable *table, const void *key) size_t parcHashCodeTable_Length(const PARCHashCodeTable *table) { - assertNotNull(table, "Parameter table must be non-null"); + parcAssertNotNull(table, "Parameter table must be non-null"); return table->hashtable.tableSize; } diff --git a/libparc/parc/algol/parc_HashMap.c b/libparc/parc/algol/parc_HashMap.c index 35a4414f..5e73a4c3 100644 --- a/libparc/parc/algol/parc_HashMap.c +++ b/libparc/parc/algol/parc_HashMap.c @@ -16,7 +16,7 @@ /** */ #include -#include +#include #include #include @@ -54,7 +54,7 @@ _parcHashMapEntry_IsValid(_PARCHashMapEntry *hashEntry) static void _parcHashMapEntry_Finalize(_PARCHashMapEntry **instancePtr) { - assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCHashMap pointer."); + parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCHashMap pointer."); _PARCHashMapEntry *hashMapEntry = *instancePtr; _parcHashMapEntry_IsValid(hashMapEntry); @@ -134,7 +134,7 @@ _parcHashMapEntry_Create(const PARCObject *key, const PARCObject *value) static void _parcHashMap_Finalize(PARCHashMap **instancePtr) { - assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCHashMap pointer."); + parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCHashMap pointer."); PARCHashMap *hashMap = *instancePtr; for (unsigned int i = 0; i < hashMap->capacity; i++) { @@ -157,7 +157,7 @@ parcObject_ExtendPARCObject(PARCHashMap, _parcHashMap_Finalize, parcHashMap_Copy void parcHashMap_AssertValid(const PARCHashMap *instance) { - assertTrue(parcHashMap_IsValid(instance), + parcAssertTrue(parcHashMap_IsValid(instance), "PARCHashMap is not valid."); } @@ -566,7 +566,7 @@ _parcHashMap_Init(PARCHashMap *map __attribute__((unused))) } } - trapOutOfMemoryIf(state->listIterator == NULL, "Cannot create parcLinkedList_CreateIterator"); + parcTrapOutOfMemoryIf(state->listIterator == NULL, "Cannot create parcLinkedList_CreateIterator"); } return state; @@ -613,7 +613,7 @@ _parcHashMap_HasNext(PARCHashMap *map __attribute__((unused)), _PARCHashMapItera if (map->buckets[state->bucket] != NULL) { parcIterator_Release(&state->listIterator); state->listIterator = parcLinkedList_CreateIterator(map->buckets[state->bucket]); - trapOutOfMemoryIf(state->listIterator == NULL, "Cannot create parcLinkedList_CreateIterator"); + parcTrapOutOfMemoryIf(state->listIterator == NULL, "Cannot create parcLinkedList_CreateIterator"); result = parcIterator_HasNext(state->listIterator); } } diff --git a/libparc/parc/algol/parc_Iterator.c b/libparc/parc/algol/parc_Iterator.c index e70a0ff9..5ef67bf4 100755 --- a/libparc/parc/algol/parc_Iterator.c +++ b/libparc/parc/algol/parc_Iterator.c @@ -77,12 +77,12 @@ parcIterator_Create(PARCObject *object, void (*fini)(PARCObject *, void *), void (*assertValid)(const void *)) { - assertNotNull(object, "PARCObject cannot be NULL."); - assertNotNull(init, "'init' function cannot be NULL."); - assertNotNull(hasNext, "'hasNext' function cannot be NULL."); - assertNotNull(next, "'next' function cannot be NULL."); - assertNotNull(element, "'element' function cannot be NULL."); - assertNotNull(fini, "'fini' function cannot be NULL."); + parcAssertNotNull(object, "PARCObject cannot be NULL."); + parcAssertNotNull(init, "'init' function cannot be NULL."); + parcAssertNotNull(hasNext, "'hasNext' function cannot be NULL."); + parcAssertNotNull(next, "'next' function cannot be NULL."); + parcAssertNotNull(element, "'element' function cannot be NULL."); + parcAssertNotNull(fini, "'fini' function cannot be NULL."); PARCIterator *result = parcObject_CreateInstance(PARCIterator); @@ -120,7 +120,7 @@ parcIterator_IsValid(const PARCIterator *iterator) void parcIterator_AssertValid(const PARCIterator *iterator) { - assertTrue(parcIterator_IsValid(iterator), "PARCIterator is not valid."); + parcAssertTrue(parcIterator_IsValid(iterator), "PARCIterator is not valid."); } parcObject_ImplementAcquire(parcIterator, PARCIterator); diff --git a/libparc/parc/algol/parc_Iterator.h b/libparc/parc/algol/parc_Iterator.h index 275a16e7..1f402cba 100644 --- a/libparc/parc/algol/parc_Iterator.h +++ b/libparc/parc/algol/parc_Iterator.h @@ -62,7 +62,7 @@ typedef struct parc_iterator PARCIterator; * * * `next` * Returns the next element in the iteration. - * If there are no remaining elements in the iteration, then this function must induce a trapOutOfBounds + * If there are no remaining elements in the iteration, then this function must induce a parcTrapOutOfBounds * * * `remove` * Removes the element returned by the `next` function. diff --git a/libparc/parc/algol/parc_JSON.c b/libparc/parc/algol/parc_JSON.c index d70a302e..f69396d2 100755 --- a/libparc/parc/algol/parc_JSON.c +++ b/libparc/parc/algol/parc_JSON.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include diff --git a/libparc/parc/algol/parc_JSONArray.c b/libparc/parc/algol/parc_JSONArray.c index 87421e12..a92e6422 100755 --- a/libparc/parc/algol/parc_JSONArray.c +++ b/libparc/parc/algol/parc_JSONArray.c @@ -18,7 +18,7 @@ #include -#include +#include #include #include @@ -54,8 +54,8 @@ static const PARCObjectDescriptor parcArrayValue_ObjInterface = { void parcJSONArray_AssertValid(const PARCJSONArray *array) { - assertNotNull(array, "Must be a non-null pointer to a PARCJSONArray instance."); - assertNotNull(array->array, "Must be a non-null pointer to a PARCDeque instance."); + parcAssertNotNull(array, "Must be a non-null pointer to a PARCJSONArray instance."); + parcAssertNotNull(array->array, "Must be a non-null pointer to a PARCDeque instance."); } PARCJSONArray * diff --git a/libparc/parc/algol/parc_JSONArray.h b/libparc/parc/algol/parc_JSONArray.h index 32fa9817..7b322867 100755 --- a/libparc/parc/algol/parc_JSONArray.h +++ b/libparc/parc/algol/parc_JSONArray.h @@ -95,7 +95,7 @@ void parcJSONArray_Release(PARCJSONArray **arrayPtr); /** * Assert that an instance of `PARCJSONArray` is valid. * - * If the instance is not valid, terminate via {@link trapIllegalValue} + * If the instance is not valid, terminate via {@link parcTrapIllegalValue} * * Valid means the internal state of the type is consistent with its required current or future behaviour. * This may include the validation of internal instances of types. diff --git a/libparc/parc/algol/parc_JSONPair.c b/libparc/parc/algol/parc_JSONPair.c index a5df700f..11676523 100755 --- a/libparc/parc/algol/parc_JSONPair.c +++ b/libparc/parc/algol/parc_JSONPair.c @@ -20,7 +20,7 @@ */ #include -#include +#include #include #include @@ -49,7 +49,7 @@ _destroyJSONPair(PARCJSONPair **pairPtr) { if (pairPtr != NULL) { PARCJSONPair *pair = *pairPtr; - assertNotNull(pair, "Parameter must be a non-null pointer to a valid PARCJSONPair."); + parcAssertNotNull(pair, "Parameter must be a non-null pointer to a valid PARCJSONPair."); parcBuffer_Release(&pair->name); parcJSONValue_Release(&pair->value); } diff --git a/libparc/parc/algol/parc_JSONParser.c b/libparc/parc/algol/parc_JSONParser.c index a0022597..a8a0510b 100755 --- a/libparc/parc/algol/parc_JSONParser.c +++ b/libparc/parc/algol/parc_JSONParser.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -59,7 +59,7 @@ parcJSONParser_Create(PARCBuffer *buffer) void parcJSONParser_AssertValid(const PARCJSONParser *parser) { - assertNotNull(parser, "PARCJSONParser cannot be NULL"); + parcAssertNotNull(parser, "PARCJSONParser cannot be NULL"); parcBuffer_OptionalAssertValid(parser->buffer); } @@ -166,7 +166,7 @@ parcJSONParser_ParseString(PARCJSONParser *parser) c = '\t'; } else if (c == 'u') { // Not supporting unicode at this point. - trapNotImplemented("Unicode is not supported."); + parcTrapNotImplemented("Unicode is not supported."); } } else if (iscntrl(c)) { // !! Syntax Error. diff --git a/libparc/parc/algol/parc_JSONParser.h b/libparc/parc/algol/parc_JSONParser.h index 18ee9d1a..425a2427 100755 --- a/libparc/parc/algol/parc_JSONParser.h +++ b/libparc/parc/algol/parc_JSONParser.h @@ -64,7 +64,7 @@ PARCJSONParser *parcJSONParser_Create(PARCBuffer *buffer); /** * Assert that an instance of `PARCJSONParser` is valid. * - * If the instance is not valid, terminate via {@link trapIllegalValue()} + * If the instance is not valid, terminate via {@link parcTrapIllegalValue()} * * Valid means the internal state of the type is consistent with its required current or future behaviour. * This may include the validation of internal instances of types. diff --git a/libparc/parc/algol/parc_JSONValue.c b/libparc/parc/algol/parc_JSONValue.c index 3a3ba9cd..f5aff0b4 100755 --- a/libparc/parc/algol/parc_JSONValue.c +++ b/libparc/parc/algol/parc_JSONValue.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -463,7 +463,7 @@ _displayNumber(const PARCJSONValue *value, int indentation) void parcJSONValue_AssertValid(const PARCJSONValue *value) { - assertNotNull(value, "PARCJSONValue cannot be NULL."); + parcAssertNotNull(value, "PARCJSONValue cannot be NULL."); } bool @@ -577,7 +577,7 @@ parcJSONValue_CreateFromString(PARCBuffer *value) PARCJSONValue * parcJSONValue_CreateFromCString(const char *value) { - assertNotNull(value, "String cannot be NULL."); + parcAssertNotNull(value, "String cannot be NULL."); PARCJSONValue *result = _createValue(PARCJSONValueType_String); if (result != NULL) { @@ -663,7 +663,7 @@ parcJSONValue_Display(const PARCJSONValue *value, int indentation) parcDisplayIndented_PrintLine(indentation + 1, ".value=null"); break; default: - trapIllegalValue(value->type, "Unknown PARCJSONValue type %d", value->type); + parcTrapIllegalValue(value->type, "Unknown PARCJSONValue type %d", value->type); } } parcDisplayIndented_PrintLine(indentation, "}"); @@ -739,7 +739,7 @@ parcJSONValue_GetArray(const PARCJSONValue *value) { parcJSONValue_OptionalAssertValid(value); - trapUnexpectedStateIf(!parcJSONValue_IsArray(value), "Expected type to be array, actual type %d", value->type); + parcTrapUnexpectedStateIf(!parcJSONValue_IsArray(value), "Expected type to be array, actual type %d", value->type); return value->value.array; } @@ -749,7 +749,7 @@ parcJSONValue_GetBoolean(const PARCJSONValue *value) { parcJSONValue_OptionalAssertValid(value); - trapUnexpectedStateIf(!parcJSONValue_IsBoolean(value), "Expected type to be boolean, actual type %d", value->type); + parcTrapUnexpectedStateIf(!parcJSONValue_IsBoolean(value), "Expected type to be boolean, actual type %d", value->type); return value->value.boolean; } @@ -793,7 +793,7 @@ parcJSONValue_GetString(const PARCJSONValue *value) { parcJSONValue_OptionalAssertValid(value); - trapUnexpectedStateIf(!parcJSONValue_IsString(value), "Expected type to be string, actual type %d", value->type); + parcTrapUnexpectedStateIf(!parcJSONValue_IsString(value), "Expected type to be string, actual type %d", value->type); return value->value.string; } @@ -803,7 +803,7 @@ parcJSONValue_GetJSON(const PARCJSONValue *value) { parcJSONValue_OptionalAssertValid(value); - trapUnexpectedStateIf(!parcJSONValue_IsJSON(value), "Expected type to be string, actual type %d", value->type); + parcTrapUnexpectedStateIf(!parcJSONValue_IsJSON(value), "Expected type to be string, actual type %d", value->type); return value->value.object; } @@ -811,7 +811,7 @@ parcJSONValue_GetJSON(const PARCJSONValue *value) struct timeval * parcJSONValue_GetTimeval(const PARCJSONValue *jsonTimeval, struct timeval *timeval) { - assertNotNull(jsonTimeval, "Parameter jsonTimeval must be a non-null PARCJSON pointer."); + parcAssertNotNull(jsonTimeval, "Parameter jsonTimeval must be a non-null PARCJSON pointer."); PARCJSON *json = parcJSONValue_GetJSON(jsonTimeval); PARCJSONValue *value = parcJSON_GetValueByName(json, "seconds"); @@ -825,7 +825,7 @@ parcJSONValue_GetTimeval(const PARCJSONValue *jsonTimeval, struct timeval *timev struct timespec * parcJSONValue_GetTimespec(const PARCJSONValue *jsonTimespec, struct timespec *timespec) { - assertNotNull(jsonTimespec, "Parameter jsonTimeval must be a non-null PARCJSON pointer."); + parcAssertNotNull(jsonTimespec, "Parameter jsonTimeval must be a non-null PARCJSON pointer."); PARCJSON *json = parcJSONValue_GetJSON(jsonTimespec); PARCJSONValue *value = parcJSON_GetValueByName(json, "seconds"); @@ -911,7 +911,7 @@ parcJSONValue_BuildString(const PARCJSONValue *value, PARCBufferComposer *compos } else if (value->type == PARCJSONValueType_Null) { parcBufferComposer_PutString(composer, "null"); } else { - trapIllegalValue(value->type, "Unknown value type: %d", value->type); + parcTrapIllegalValue(value->type, "Unknown value type: %d", value->type); } return composer; diff --git a/libparc/parc/algol/parc_JSONValue.h b/libparc/parc/algol/parc_JSONValue.h index 300a1c0c..0f93b2bc 100755 --- a/libparc/parc/algol/parc_JSONValue.h +++ b/libparc/parc/algol/parc_JSONValue.h @@ -174,7 +174,7 @@ bool parcJSONValue_IsValid(const PARCJSONValue *value); /** * Assert that an instance of `PARCJSONValue` is valid. * - * If the instance is not valid, terminate via {@link trapIllegalValue()} + * If the instance is not valid, terminate via {@link parcTrapIllegalValue()} * * Valid means the internal state of the type is consistent with its required current or future behaviour. * This may include the validation of internal instances of types. diff --git a/libparc/parc/algol/parc_KeyValue.c b/libparc/parc/algol/parc_KeyValue.c index 27b20f35..352bf3e8 100755 --- a/libparc/parc/algol/parc_KeyValue.c +++ b/libparc/parc/algol/parc_KeyValue.c @@ -24,7 +24,7 @@ #include "parc_KeyValue.h" #include "parc_Object.h" -#include +#include struct parc_key_value { PARCObject *key; @@ -52,10 +52,10 @@ PARCKeyValue * parcKeyValue_Create(const PARCObject *key, const PARCObject *value) { - assertNotNull(key, "Key may not be null in a KeyValue element"); + parcAssertNotNull(key, "Key may not be null in a KeyValue element"); PARCKeyValue *keyValue = parcObject_CreateInstance(PARCKeyValue); - assertNotNull(keyValue, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyValue)); + parcAssertNotNull(keyValue, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyValue)); keyValue->key = parcObject_Acquire(key); keyValue->value = NULL; @@ -82,7 +82,7 @@ parcKeyValue_Copy(const PARCKeyValue *source) void parcKeyValue_SetValue(PARCKeyValue *keyValue, PARCObject *value) { - assertNotNull(keyValue, "Not a valid keyValue"); + parcAssertNotNull(keyValue, "Not a valid keyValue"); PARCObject *oldValue = keyValue->value; if (value != NULL) { keyValue->value = parcObject_Acquire(value); @@ -97,7 +97,7 @@ parcKeyValue_SetValue(PARCKeyValue *keyValue, PARCObject *value) void parcKeyValue_SetKey(PARCKeyValue *keyValue, PARCObject *key) { - assertNotNull(keyValue, "Not a valid keyValue"); + parcAssertNotNull(keyValue, "Not a valid keyValue"); PARCObject *oldKey = keyValue->key; keyValue->key = parcObject_Acquire(key); parcObject_Release(&oldKey); @@ -106,14 +106,14 @@ parcKeyValue_SetKey(PARCKeyValue *keyValue, PARCObject *key) PARCObject * parcKeyValue_GetValue(PARCKeyValue *keyValue) { - assertNotNull(keyValue, "Not a valid keyValue"); + parcAssertNotNull(keyValue, "Not a valid keyValue"); return keyValue->value; } PARCObject * parcKeyValue_GetKey(PARCKeyValue *keyValue) { - assertNotNull(keyValue, "Not a valid keyValue"); + parcAssertNotNull(keyValue, "Not a valid keyValue"); return keyValue->key; } diff --git a/libparc/parc/algol/parc_KeyedElement.c b/libparc/parc/algol/parc_KeyedElement.c index a55de891..265987cd 100755 --- a/libparc/parc/algol/parc_KeyedElement.c +++ b/libparc/parc/algol/parc_KeyedElement.c @@ -21,7 +21,7 @@ #include -#include +#include #include #include @@ -36,10 +36,10 @@ PARCKeyedElement * parcKeyedElement_Create(void *data, const void *key, size_t keylen) { PARCKeyedElement *keyedElement = parcMemory_Allocate(sizeof(PARCKeyedElement)); - assertNotNull(keyedElement, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyedElement)); + parcAssertNotNull(keyedElement, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyedElement)); keyedElement->element = data; keyedElement->key = parcMemory_Allocate(sizeof(PARCKeyedElement)); - assertNotNull(keyedElement->key, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyedElement)); + parcAssertNotNull(keyedElement->key, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCKeyedElement)); memcpy(keyedElement->key, key, keylen); keyedElement->keylen = keylen; return keyedElement; diff --git a/libparc/parc/algol/parc_LinkedList.c b/libparc/parc/algol/parc_LinkedList.c index d220e223..b5bbd0a6 100644 --- a/libparc/parc/algol/parc_LinkedList.c +++ b/libparc/parc/algol/parc_LinkedList.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -136,7 +136,7 @@ static void _parcLinkedListIterator_IsValid(const _PARCLinkedListNode *node) { if (node != NULL) { - assertTrue(_parcLinkedListNode_IsValid(node), "node is invalid"); + parcAssertTrue(_parcLinkedListNode_IsValid(node), "node is invalid"); } } @@ -183,12 +183,12 @@ _parcLinkedListNode_Next(PARCLinkedList *list __attribute__((unused)), const _PA if (node == NULL) { result = list->head; } else { - assertTrue(_parcLinkedListNode_IsValid(node), "node is invalid"); - trapOutOfBoundsIf(node->next == NULL, "No more elements."); + parcAssertTrue(_parcLinkedListNode_IsValid(node), "node is invalid"); + parcTrapOutOfBoundsIf(node->next == NULL, "No more elements."); result = node->next; } - assertTrue(_parcLinkedListNode_IsValid(result), "result is invalid"); + parcAssertTrue(_parcLinkedListNode_IsValid(result), "result is invalid"); parcObject_OptionalAssertValid(result->object); return result; @@ -244,12 +244,12 @@ _parcLinkedListNode_HasNext(PARCLinkedList *list, const _PARCLinkedListNode *nod if (node == NULL) { result = (list->head != NULL); if (result) { - assertTrue(_parcLinkedListNode_IsValid(list->head), "node is invalid"); + parcAssertTrue(_parcLinkedListNode_IsValid(list->head), "node is invalid"); } } else { result = node->next != NULL; if (result) { - assertTrue(_parcLinkedListNode_IsValid(node->next), "node is invalid"); + parcAssertTrue(_parcLinkedListNode_IsValid(node->next), "node is invalid"); } } @@ -333,7 +333,7 @@ parcLinkedList_IsValid(const PARCLinkedList *list) void parcLinkedList_AssertValid(const PARCLinkedList *instance) { - assertTrue(parcLinkedList_IsValid(instance), + parcAssertTrue(parcLinkedList_IsValid(instance), "PARCLinkedList is not valid."); } @@ -462,7 +462,7 @@ parcLinkedList_RemoveLast(PARCLinkedList *list) bool parcLinkedList_Remove(PARCLinkedList *list, const PARCObject *element) { - assertTrue(element != NULL, "Element must not be NULL"); + parcAssertTrue(element != NULL, "Element must not be NULL"); bool result = false; _PARCLinkedListNode *node = _parcLinkedListNode_getByValue(list, element); @@ -592,7 +592,7 @@ parcLinkedList_SetAtIndex(PARCLinkedList *list, size_t index, PARCObject *elemen PARCObject *result = NULL; if (index > (parcLinkedList_Size(list) - 1)) { - trapOutOfBounds(index, "[0, %zd]", parcLinkedList_Size(list) - 1); + parcTrapOutOfBounds(index, "[0, %zd]", parcLinkedList_Size(list) - 1); } _PARCLinkedListNode *node = _parcLinkedListNode_getByIndex(list, index); @@ -607,7 +607,7 @@ PARCObject * parcLinkedList_GetAtIndex(const PARCLinkedList *list, size_t index) { if (index > (parcLinkedList_Size(list) - 1)) { - trapOutOfBounds(index, "[0, %zd]", parcLinkedList_Size(list) - 1); + parcTrapOutOfBounds(index, "[0, %zd]", parcLinkedList_Size(list) - 1); } _PARCLinkedListNode *node = _parcLinkedListNode_getByIndex(list, index); diff --git a/libparc/parc/algol/parc_LinkedList.h b/libparc/parc/algol/parc_LinkedList.h index 7babff79..381e2a18 100644 --- a/libparc/parc/algol/parc_LinkedList.h +++ b/libparc/parc/algol/parc_LinkedList.h @@ -421,7 +421,7 @@ bool parcLinkedList_IsEmpty(const PARCLinkedList *list); * @param [in] list A pointer to a `PARCLinkedList` instance. * @param [in] index The index of the element to be retrieved. * - * @throws `trapOutOfBounds` + * @throws `parcTrapOutOfBounds` * * Example: * @code @@ -437,7 +437,7 @@ PARCObject *parcLinkedList_GetAtIndex(const PARCLinkedList *list, size_t index); * @param [in] index The index of the element to be replaced. * @param [in] element A pointer to a valid PARCObject instance that will replace the current element at @p index. * - * @throws `trapOutOfBounds` + * @throws `parcTrapOutOfBounds` * * Example: * @code diff --git a/libparc/parc/algol/parc_List.c b/libparc/parc/algol/parc_List.c index 0e62cda6..bdb343f8 100644 --- a/libparc/parc/algol/parc_List.c +++ b/libparc/parc/algol/parc_List.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include diff --git a/libparc/parc/algol/parc_List.h b/libparc/parc/algol/parc_List.h index 6c17453c..d6d94adf 100644 --- a/libparc/parc/algol/parc_List.h +++ b/libparc/parc/algol/parc_List.h @@ -364,7 +364,7 @@ void parcList_Release(PARCList **listPtr); * @return NULL Memory could not be allocated. * @return non-NULL A pointer to a new `PARCList` instance. * - * @throws trapIllegalValue if @p instance is NULL. + * @throws parcTrapIllegalValue if @p instance is NULL. * * Example: * @code @@ -429,7 +429,7 @@ bool parcList_Add(PARCList *list, void *element); * parcList_AddAll(array, 3, elements); * size_t actual = parcList_Length(array); * - * assertTrue(3 == actual, "Expected=%d, actual=%d", 3, actual); + * parcAssertTrue(3 == actual, "Expected=%d, actual=%d", 3, actual); * * parcListRelease(&array); * } diff --git a/libparc/parc/algol/parc_Memory.c b/libparc/parc/algol/parc_Memory.c index e444baba..eebdadf0 100755 --- a/libparc/parc/algol/parc_Memory.c +++ b/libparc/parc/algol/parc_Memory.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -37,7 +37,7 @@ static const PARCMemoryInterface *parcMemory = &PARCStdlibMemoryAsPARCMemory; const PARCMemoryInterface * parcMemory_SetInterface(const PARCMemoryInterface *memoryProvider) { - assertFalse(memoryProvider == &PARCMemoryAsPARCMemory, + parcAssertFalse(memoryProvider == &PARCMemoryAsPARCMemory, "You cannot use PARCMemoryAsPARCMemory as a memory provider for parcMemory."); const PARCMemoryInterface *result = parcMemory; parcMemory = memoryProvider; diff --git a/libparc/parc/algol/parc_Network.c b/libparc/parc/algol/parc_Network.c index 35279648..2b6c8888 100644 --- a/libparc/parc/algol/parc_Network.c +++ b/libparc/parc/algol/parc_Network.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -49,9 +49,9 @@ parcNetwork_SockAddress(const char *address, in_port_t port) switch (ai->ai_family) { case PF_INET: { struct sockaddr_in *result = parcMemory_AllocateAndClear(sizeof(struct sockaddr_in)); - assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in)); + parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in)); if (result != NULL) { - assertTrue(ai->ai_addrlen == sizeof(struct sockaddr_in), + parcAssertTrue(ai->ai_addrlen == sizeof(struct sockaddr_in), "Sockaddr wrong length, expected %zu got %u", sizeof(struct sockaddr_in), ai->ai_addrlen); memcpy(result, ai->ai_addr, ai->ai_addrlen); result->sin_port = htons(port); @@ -62,9 +62,9 @@ parcNetwork_SockAddress(const char *address, in_port_t port) case PF_INET6: { struct sockaddr_in6 *result = parcMemory_AllocateAndClear(sizeof(struct sockaddr_in6)); - assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in6)); + parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in6)); if (result != NULL) { - assertTrue(ai->ai_addrlen == sizeof(struct sockaddr_in6), + parcAssertTrue(ai->ai_addrlen == sizeof(struct sockaddr_in6), "Sockaddr wrong length, expected %zu got %u", sizeof(struct sockaddr_in6), ai->ai_addrlen); memcpy(result, ai->ai_addr, ai->ai_addrlen); @@ -93,7 +93,7 @@ struct sockaddr_in * parcNetwork_SockInet4Address(const char *address, in_port_t port) { struct sockaddr_in *result = parcMemory_AllocateAndClear(sizeof(struct sockaddr_in)); - assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in)); + parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in)); if (result != NULL) { result->sin_family = AF_INET; result->sin_port = htons(port); @@ -113,7 +113,7 @@ struct sockaddr_in6 * parcNetwork_SockInet6Address(const char *address, in_port_t port, uint32_t flowInfo, uint32_t scopeId) { struct sockaddr_in6 *result = parcMemory_AllocateAndClear(sizeof(struct sockaddr_in6)); - assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in6)); + parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in6)); if (result != NULL) { result->sin6_family = AF_INET6; result->sin6_port = htons(port); @@ -136,7 +136,7 @@ struct sockaddr_in * parcNetwork_SockInet4AddressAny() { struct sockaddr_in *result = parcMemory_AllocateAndClear(sizeof(struct sockaddr_in)); - assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in)); + parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(struct sockaddr_in)); if (result != NULL) { result->sin_family = AF_INET; result->sin_addr.s_addr = INADDR_ANY; @@ -151,10 +151,10 @@ parcNetwork_SockInet4AddressAny() PARCBufferComposer * parcNetwork_SockInet4Address_BuildString(const struct sockaddr_in *address, PARCBufferComposer *composer) { - assertNotNull(address, "Parameter must be a non-null pointer to a struct sockaddr_in."); + parcAssertNotNull(address, "Parameter must be a non-null pointer to a struct sockaddr_in."); if (address->sin_family != AF_INET) { - trapIllegalValue(address->sin_family, "Expected an AF_INET configured address, not %d", address->sin_family); + parcTrapIllegalValue(address->sin_family, "Expected an AF_INET configured address, not %d", address->sin_family); } char buffer[INET_ADDRSTRLEN]; @@ -167,10 +167,10 @@ parcNetwork_SockInet4Address_BuildString(const struct sockaddr_in *address, PARC PARCBufferComposer * parcNetwork_SockInet6Address_BuildString(const struct sockaddr_in6 *address, PARCBufferComposer *composer) { - assertNotNull(address, "Parameter must be a non-null pointer to a struct sockaddr_in."); + parcAssertNotNull(address, "Parameter must be a non-null pointer to a struct sockaddr_in."); if (address->sin6_family != AF_INET6) { - trapIllegalValue(address->sin_family, "Expected an AF_INET6 configured address, not %d", address->sin6_family); + parcTrapIllegalValue(address->sin_family, "Expected an AF_INET6 configured address, not %d", address->sin6_family); } char buffer[INET6_ADDRSTRLEN]; @@ -297,13 +297,13 @@ parcNetwork_ParseLinkAddress(const char *address) if (parcNetwork_ParseMAC48Address(&address[7], result) == false) { parcBuffer_Release(&result); - trapIllegalValue(address, "Syntax error '%s'", address); + parcTrapIllegalValue(address, "Syntax error '%s'", address); } return parcBuffer_Flip(result); } - trapIllegalValue(address, "Bad scheme '%s'", address); + parcTrapIllegalValue(address, "Bad scheme '%s'", address); } bool @@ -366,7 +366,7 @@ _isInet4Loopback(struct sockaddr_in *sin4) bool parcNetwork_IsSocketLocal(struct sockaddr *sock) { - assertNotNull(sock, "Parameter sock must be non-null"); + parcAssertNotNull(sock, "Parameter sock must be non-null"); bool isLocal = false; switch (sock->sa_family) { diff --git a/libparc/parc/algol/parc_Network.h b/libparc/parc/algol/parc_Network.h index efd5e632..bf7cfcbd 100644 --- a/libparc/parc/algol/parc_Network.h +++ b/libparc/parc/algol/parc_Network.h @@ -55,24 +55,24 @@ typedef uint16_t in_port_t; * { * struct sockaddr *addr; * addr = parcNetwork_SockAddress("1.2.3.4", 555); - * assertTrue(addr && addr->sa_family == AF_INET, "Addr not IPv4 for a dotted quad."); + * parcAssertTrue(addr && addr->sa_family == AF_INET, "Addr not IPv4 for a dotted quad."); * struct sockaddr_in *addr_in = (struct sockaddr_in *) addr; * // ... * parcMemory_Deallocate((void **)&addr); * * addr = parcNetwork_SockAddress("fe80::aa20:66ff:fe00:314a", 555); - * assertTrue(addr && addr->sa_family == AF_INET6, "Addr not IPv6."); + * parcAssertTrue(addr && addr->sa_family == AF_INET6, "Addr not IPv6."); * struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *) addr; * // ... * parcMemory_Deallocate((void **)&addr); * * addr = parcNetwork_SockAddress("alpha.parc.com", 555); - * assertTrue(addr && addr->sa_family == AF_INET, "Addr not IPv4 hostname with only ipv4 address."); + * parcAssertTrue(addr && addr->sa_family == AF_INET, "Addr not IPv4 hostname with only ipv4 address."); * // ... * parcMemory_Deallocate((void **)&addr); * * addr = parcNetwork_SockAddress("Over the rainbow, way up high", 555); - * assertNull(addr, "Addr no null for bogus name."); + * parcAssertNull(addr, "Addr no null for bogus name."); * * } * @endcode @@ -256,7 +256,7 @@ struct sockaddr_in *parcNetwork_ParseInet4Address(const char *addressURI); * @code * { * struct sockaddr *s = parcNetwork_SockAddress("127.1.1.1", 5900); - * assertTrue(parcNetwork_IsSocketLocal(s), "This will not assert"); + * parcAssertTrue(parcNetwork_IsSocketLocal(s), "This will not assert"); * parcMemory_Deallocate((void **)&s); * } * @endcode diff --git a/libparc/parc/algol/parc_Object.c b/libparc/parc/algol/parc_Object.c index 578f1e1a..70a24f34 100644 --- a/libparc/parc/algol/parc_Object.c +++ b/libparc/parc/algol/parc_Object.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -246,7 +246,7 @@ _parcObject_ToString(const PARCObject *object) "Object@%p { .references=%" PRId64 ", .objectLength = %zd, .objectAlignment=%u } data %p\n", (void *) header, header->references, header->descriptor->objectSize, header->descriptor->objectAlignment, object); - assertTrue(nwritten >= 0, "Error calling asprintf"); + parcAssertTrue(nwritten >= 0, "Error calling asprintf"); char *result = parcMemory_StringDuplicate(string, strlen(string)); free(string); return result; @@ -265,7 +265,7 @@ _parcObject_ToJSON(const PARCObject *object) char *addressString; int nwritten = asprintf(&addressString, "%p", object); - assertTrue(nwritten >= 0, "Error calling asprintf"); + parcAssertTrue(nwritten >= 0, "Error calling asprintf"); parcJSON_AddString(json, "address", addressString); @@ -335,17 +335,17 @@ parcObject_IsValid(const PARCObject *object) static inline void _parcObjectHeader_AssertValid(const _PARCObjectHeader *header, const PARCObject *object) { - trapIllegalValueIf(header->magicGuardNumber != PARCObject_HEADER_MAGIC_GUARD_NUMBER, "PARCObject@%p is corrupt.", object); - trapIllegalValueIf(header->descriptor == NULL, "PARCObject@%p descriptor cannot be NULL.", object); + parcTrapIllegalValueIf(header->magicGuardNumber != PARCObject_HEADER_MAGIC_GUARD_NUMBER, "PARCObject@%p is corrupt.", object); + parcTrapIllegalValueIf(header->descriptor == NULL, "PARCObject@%p descriptor cannot be NULL.", object); if (header->descriptor->isLockable) { - trapIllegalValueIf(header->locking == NULL, "PARCObject@%p is corrupt. Is Lockable but no locking structure", object); + parcTrapIllegalValueIf(header->locking == NULL, "PARCObject@%p is corrupt. Is Lockable but no locking structure", object); } } static inline void _parcObject_AssertValid(const PARCObject *object) { - trapIllegalValueIf(object == NULL, "PARCObject must be a non-null pointer."); + parcTrapIllegalValueIf(object == NULL, "PARCObject must be a non-null pointer."); _PARCObjectHeader *header = _parcObject_Header(object); _parcObjectHeader_AssertValid(header, object); @@ -628,7 +628,7 @@ parcObject_Release(PARCObject **objectPointer) _PARCObjectHeader *header = _parcObject_Header(object); - trapIllegalValueIf(header->references == 0, "PARCObject@%p references must be > 0", object); + parcTrapIllegalValueIf(header->references == 0, "PARCObject@%p references must be > 0", object); PARCReferenceCount result = parcAtomicUint64_Decrement(&header->references); @@ -641,9 +641,9 @@ parcObject_Release(PARCObject **objectPointer) void *origin = _parcObject_Origin(object); parcMemory_Deallocate(&origin); } - assertNotNull(*objectPointer, "Class implementation unnecessarily clears the object pointer."); + parcAssertNotNull(*objectPointer, "Class implementation unnecessarily clears the object pointer."); } else { - assertNull(*objectPointer, "Class implementation must clear the object pointer."); + parcAssertNull(*objectPointer, "Class implementation must clear the object pointer."); } } @@ -675,7 +675,7 @@ const PARCObjectDescriptor * parcObject_SetDescriptor(PARCObject *object, const PARCObjectDescriptor *descriptor) { parcObject_OptionalAssertValid(object); - assertNotNull(descriptor, "PARCObjectDescriptor cannot be NULL."); + parcAssertNotNull(descriptor, "PARCObjectDescriptor cannot be NULL."); _PARCObjectHeader *header = _parcObject_Header(object); @@ -702,7 +702,7 @@ parcObjectDescriptor_Create(const char *name, const PARCObjectDescriptor *superType, PARCObjectTypeState *typeState) { - assertNotNull(superType, "Supertype descriptor cannot be NULL."); + parcAssertNotNull(superType, "Supertype descriptor cannot be NULL."); PARCObjectDescriptor *result = parcMemory_AllocateAndClear(sizeof(PARCObjectDescriptor)); if (result != NULL) { @@ -773,7 +773,7 @@ parcObject_Unlock(const PARCObject *object) locking->locker = (pthread_t) NULL; result = (pthread_mutex_unlock(&locking->lock) == 0); - assertTrue(result, "Attempted to unlock an unowned lock."); + parcAssertTrue(result, "Attempted to unlock an unowned lock."); } } } @@ -793,7 +793,7 @@ parcObject_Lock(const PARCObject *object) if (object != NULL) { _PARCObjectLocking *locking = _parcObjectHeader_Locking(object); if (locking != NULL) { - trapCannotObtainLockIf(pthread_equal(locking->locker, pthread_self()), + parcTrapCannotObtainLockIf(pthread_equal(locking->locker, pthread_self()), "Recursive locks on %p are not supported.", object); errno = pthread_mutex_lock(&locking->lock); @@ -818,7 +818,7 @@ parcObject_TryLock(const PARCObject *object) _PARCObjectLocking *locking = _parcObjectHeader_Locking(object); if (locking != NULL) { - trapCannotObtainLockIf(pthread_equal(locking->locker, pthread_self()), "Recursive locks are not supported."); + parcTrapCannotObtainLockIf(pthread_equal(locking->locker, pthread_self()), "Recursive locks are not supported."); int lockStatus = pthread_mutex_trylock(&locking->lock); diff --git a/libparc/parc/algol/parc_Object.h b/libparc/parc/algol/parc_Object.h index 0f3a932b..b1a48558 100644 --- a/libparc/parc/algol/parc_Object.h +++ b/libparc/parc/algol/parc_Object.h @@ -42,8 +42,7 @@ #include #include -#include -#include +#include #include //#include @@ -598,8 +597,9 @@ const PARCObjectDescriptor *parcObject_SetDescriptor(PARCObject *object, const P * Create new `PARCObjectDescriptor` based on an existing `PARCObjectDescriptor.` * The new `PARCObjectDescriptor` uses the existing `PARCObjectDescriptor` as the super-type of the new descriptor. */ + #define parcObject_Extends(_subtype, _superType, ...) \ - LongBowCompiler_IgnoreInitializerOverrides \ + _Pragma("GCC diagnostic ignored \"-Woverride-init\"") \ parcObjectDescriptor_Declaration(_subtype) = { \ .super = &parcObject_DescriptorName(_superType), \ .name = #_subtype, \ @@ -619,7 +619,7 @@ const PARCObjectDescriptor *parcObject_SetDescriptor(PARCObject *object, const P .typeState = NULL, \ __VA_ARGS__ \ }; \ - LongBowCompiler_WarnInitializerOverrides \ + _Pragma("GCC diagnostic warning \"-Woverride-init\"") \ const PARCObjectDescriptor parcObject_DescriptorName(_subtype) /** diff --git a/libparc/parc/algol/parc_OldSortedList.c b/libparc/parc/algol/parc_OldSortedList.c index ef007388..c50d856d 100755 --- a/libparc/parc/algol/parc_OldSortedList.c +++ b/libparc/parc/algol/parc_OldSortedList.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include @@ -33,7 +33,7 @@ PARCSortedList * parcSortedList_Create(parcSortedList_Compare compareFunction) { PARCSortedList *sortedList = parcMemory_Allocate(sizeof(PARCSortedList)); - assertNotNull(sortedList, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCSortedList)); + parcAssertNotNull(sortedList, "parcMemory_Allocate(%zu) returned NULL", sizeof(PARCSortedList)); sortedList->arrayList = parcArrayList_Create(NULL); sortedList->compare = compareFunction; return sortedList; @@ -50,9 +50,9 @@ parcSortedList_Destroy(PARCSortedList **parcSortedListPointer) void parcSortedList_Add(PARCSortedList *parcSortedList, void *newItem) { - assertNotNull(parcSortedList, "sortedList parameter can't be null"); - assertNotNull(parcSortedList->arrayList, "arrayList can't be null"); - assertNotNull(newItem, "newItem can't be null"); + parcAssertNotNull(parcSortedList, "sortedList parameter can't be null"); + parcAssertNotNull(parcSortedList->arrayList, "arrayList can't be null"); + parcAssertNotNull(newItem, "newItem can't be null"); size_t total_items = parcArrayList_Size(parcSortedList->arrayList); for (size_t i = 0; i < total_items; i++) { @@ -77,8 +77,8 @@ parcSortedList_Length(PARCSortedList *parcSortedList) void * parcSortedList_PopFirst(PARCSortedList *parcSortedList) { - assertNotNull(parcSortedList, "sortedList parameter can't be null"); - assertNotNull(parcSortedList->arrayList, "arrayList can't be null"); + parcAssertNotNull(parcSortedList, "sortedList parameter can't be null"); + parcAssertNotNull(parcSortedList->arrayList, "arrayList can't be null"); if (parcArrayList_Size(parcSortedList->arrayList) == 0) { return NULL; @@ -91,8 +91,8 @@ parcSortedList_PopFirst(PARCSortedList *parcSortedList) void * parcSortedList_GetFirst(PARCSortedList *parcSortedList) { - assertNotNull(parcSortedList, "sortedList parameter can't be null"); - assertNotNull(parcSortedList->arrayList, "arrayList can't be null"); + parcAssertNotNull(parcSortedList, "sortedList parameter can't be null"); + parcAssertNotNull(parcSortedList->arrayList, "arrayList can't be null"); if (parcArrayList_Size(parcSortedList->arrayList) == 0) { return NULL; diff --git a/libparc/parc/algol/parc_PathName.c b/libparc/parc/algol/parc_PathName.c index e329ee88..56e57d27 100755 --- a/libparc/parc/algol/parc_PathName.c +++ b/libparc/parc/algol/parc_PathName.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include diff --git a/libparc/parc/algol/parc_PriorityQueue.c b/libparc/parc/algol/parc_PriorityQueue.c index 93744b2c..c6c003b1 100755 --- a/libparc/parc/algol/parc_PriorityQueue.c +++ b/libparc/parc/algol/parc_PriorityQueue.c @@ -30,7 +30,7 @@ #include -#include +#include #include #include @@ -263,8 +263,8 @@ _expand(PARCPriorityQueue *queue) void parcPriorityQueue_ParcFreeDestroyer(void **elementPtr) { - assertNotNull(elementPtr, "Double pointer must be non-null"); - assertNotNull(*elementPtr, "Double pointer must dereference to non-null"); + parcAssertNotNull(elementPtr, "Double pointer must be non-null"); + parcAssertNotNull(*elementPtr, "Double pointer must dereference to non-null"); void *element = *elementPtr; parcMemory_Deallocate((void **) &element); *elementPtr = NULL; @@ -286,13 +286,13 @@ parcPriorityQueue_Uint64CompareTo(const void *a, const void *b) PARCPriorityQueue * parcPriorityQueue_Create(PARCPriorityQueueCompareTo *compare, PARCPriorityQueueDestroyer *destroyer) { - assertNotNull(compare, "Parameter compare must be non-null"); + parcAssertNotNull(compare, "Parameter compare must be non-null"); size_t initialSize = 128; PARCPriorityQueue *queue = parcMemory_AllocateAndClear(sizeof(PARCPriorityQueue)); - assertNotNull(queue, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCPriorityQueue)); + parcAssertNotNull(queue, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCPriorityQueue)); queue->array = parcMemory_AllocateAndClear(sizeof(HeapEntry) * initialSize); - assertNotNull(queue->array, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(HeapEntry) * initialSize); + parcAssertNotNull(queue->array, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(HeapEntry) * initialSize); queue->capacity = initialSize; queue->size = 0; queue->compare = compare; @@ -304,8 +304,8 @@ parcPriorityQueue_Create(PARCPriorityQueueCompareTo *compare, PARCPriorityQueueD void parcPriorityQueue_Destroy(PARCPriorityQueue **queuePtr) { - assertNotNull(queuePtr, "Double pointer must be non-null"); - assertNotNull(*queuePtr, "Double pointer must dereference to non-null"); + parcAssertNotNull(queuePtr, "Double pointer must be non-null"); + parcAssertNotNull(*queuePtr, "Double pointer must dereference to non-null"); PARCPriorityQueue *queue = *queuePtr; parcPriorityQueue_Clear(queue); parcMemory_Deallocate((void **) &(queue->array)); @@ -316,8 +316,8 @@ parcPriorityQueue_Destroy(PARCPriorityQueue **queuePtr) bool parcPriorityQueue_Add(PARCPriorityQueue *queue, void *data) { - assertNotNull(queue, "Parameter queue must be non-null"); - assertNotNull(data, "Parameter data must be non-null"); + parcAssertNotNull(queue, "Parameter queue must be non-null"); + parcAssertNotNull(data, "Parameter data must be non-null"); if (queue->size + 1 > queue->capacity) { _expand(queue); @@ -338,7 +338,7 @@ parcPriorityQueue_Add(PARCPriorityQueue *queue, void *data) void parcPriorityQueue_Clear(PARCPriorityQueue *queue) { - assertNotNull(queue, "Parameter queue must be non-null"); + parcAssertNotNull(queue, "Parameter queue must be non-null"); if (queue->destroyer != NULL) { for (size_t i = 0; i < queue->size; i++) { queue->destroyer(&queue->array[i].data); @@ -351,7 +351,7 @@ parcPriorityQueue_Clear(PARCPriorityQueue *queue) void * parcPriorityQueue_Peek(PARCPriorityQueue *queue) { - assertNotNull(queue, "Parameter queue must be non-null"); + parcAssertNotNull(queue, "Parameter queue must be non-null"); if (queue->size > 0) { return queue->array[0].data; } @@ -361,7 +361,7 @@ parcPriorityQueue_Peek(PARCPriorityQueue *queue) void * parcPriorityQueue_Poll(PARCPriorityQueue *queue) { - assertNotNull(queue, "Parameter queue must be non-null"); + parcAssertNotNull(queue, "Parameter queue must be non-null"); if (queue->size > 0) { void *data = queue->array[0].data; @@ -382,6 +382,6 @@ parcPriorityQueue_Poll(PARCPriorityQueue *queue) size_t parcPriorityQueue_Size(const PARCPriorityQueue *queue) { - assertNotNull(queue, "Parameter queue must be non-null"); + parcAssertNotNull(queue, "Parameter queue must be non-null"); return queue->size; } diff --git a/libparc/parc/algol/parc_Properties.c b/libparc/parc/algol/parc_Properties.c index 19aea290..2a6c7d33 100644 --- a/libparc/parc/algol/parc_Properties.c +++ b/libparc/parc/algol/parc_Properties.c @@ -18,7 +18,7 @@ #include #include -#include +#include #include #include @@ -35,7 +35,7 @@ struct PARCProperties { static void _parcProperties_Finalize(PARCProperties **instancePtr) { - assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCProperties pointer."); + parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCProperties pointer."); PARCProperties *instance = *instancePtr; parcProperties_OptionalAssertValid(instance); @@ -53,7 +53,7 @@ parcObject_ExtendPARCObject(PARCProperties, _parcProperties_Finalize, parcProper void parcProperties_AssertValid(const PARCProperties *instance) { - assertTrue(parcProperties_IsValid(instance), + parcAssertTrue(parcProperties_IsValid(instance), "PARCProperties is not valid."); } @@ -94,7 +94,7 @@ void parcProperties_Display(const PARCProperties *properties, int indentation) { parcDisplayIndented_PrintLine(indentation, "PARCProperties@%p {", properties); - trapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object."); + parcTrapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object."); PARCIterator *iterator = parcHashMap_CreateKeyIterator(properties->properties); while (parcIterator_HasNext(iterator)) { @@ -151,7 +151,7 @@ parcProperties_ToJSON(const PARCProperties *properties) { PARCJSON *result = parcJSON_Create(); - trapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object."); + parcTrapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object."); PARCIterator *iterator = parcHashMap_CreateKeyIterator(properties->properties); while (parcIterator_HasNext(iterator)) { @@ -170,7 +170,7 @@ parcProperties_ToJSON(const PARCProperties *properties) PARCBufferComposer * parcProperties_BuildString(const PARCProperties *properties, PARCBufferComposer *composer) { - trapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object."); + parcTrapCannotObtainLockIf(parcHashMap_Lock(properties->properties) == false, "Cannot lock PARCProperties object."); PARCIterator *iterator = parcHashMap_CreateKeyIterator(properties->properties); while (parcIterator_HasNext(iterator)) { diff --git a/libparc/parc/algol/parc_RandomAccessFile.c b/libparc/parc/algol/parc_RandomAccessFile.c index 65bff1d1..9a5e7914 100755 --- a/libparc/parc/algol/parc_RandomAccessFile.c +++ b/libparc/parc/algol/parc_RandomAccessFile.c @@ -33,7 +33,7 @@ struct PARCRandomAccessFile { static void _parcRandomAccessFile_Finalize(PARCRandomAccessFile **instancePtr) { - assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCRandomAccessFile pointer."); + parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCRandomAccessFile pointer."); PARCRandomAccessFile *instance = *instancePtr; if (instance->fhandle != NULL) { fclose(instance->fhandle); @@ -55,7 +55,7 @@ parcObject_ExtendPARCObject(PARCRandomAccessFile, _parcRandomAccessFile_Finalize void parcRandomAccessFile_AssertValid(const PARCRandomAccessFile *instance) { - assertTrue(parcRandomAccessFile_IsValid(instance), + parcAssertTrue(parcRandomAccessFile_IsValid(instance), "PARCRandomAccessFile is not valid."); } @@ -138,7 +138,7 @@ parcRandomAccessFile_Open(PARCFile *file) bool parcRandomAccessFile_Close(PARCRandomAccessFile *fileHandle) { - assertNotNull(fileHandle->fhandle, "Can't fclose a null pointer. How did they get one anyway?"); + parcAssertNotNull(fileHandle->fhandle, "Can't fclose a null pointer. How did they get one anyway?"); bool result = fclose(fileHandle->fhandle) == 0; fileHandle->fhandle = NULL; parcMemory_Deallocate(&fileHandle->fname); @@ -179,7 +179,7 @@ parcRandomAccessFile_Seek(PARCRandomAccessFile *fileHandle, long offset, PARCRan result = fseek(fileHandle->fhandle, offset, SEEK_END); // end of the file break; default: - assertTrue(false, "Invalid position %d", position); + parcAssertTrue(false, "Invalid position %d", position); } return result; } diff --git a/libparc/parc/algol/parc_SafeMemory.c b/libparc/parc/algol/parc_SafeMemory.c index 1f152af9..76908548 100644 --- a/libparc/parc/algol/parc_SafeMemory.c +++ b/libparc/parc/algol/parc_SafeMemory.c @@ -36,7 +36,7 @@ */ #include -#include +#include #if defined(_WIN64) # define backtrace(...) (0) @@ -340,7 +340,7 @@ _parcSafeMemory_Report(const PARCSafeMemoryUsable *safeMemory, int outputFd) (void *) safeMemory, (void *) prefix, _parcSafeMemory_StateToString(_parcSafeMemory_GetState(safeMemory))); - trapUnexpectedStateIf(charactersPrinted < 0, "Cannot write to file descriptor %d", outputFd); + parcTrapUnexpectedStateIf(charactersPrinted < 0, "Cannot write to file descriptor %d", outputFd); } _backtraceReport(prefix->backtrace, outputFd); } @@ -359,7 +359,7 @@ parcSafeMemory_ReportAllocation(int outputFd) int charactersPrinted = dprintf(outputFd, "\n%u SafeMemory@%p: %p={ .requestedLength=%zd, .actualLength=%zd, .alignment=%zd }\n", index, e->memory, (void *) prefix, prefix->requestedLength, prefix->actualLength, prefix->alignment); - trapUnexpectedStateIf(charactersPrinted < 0, "Cannot write to file descriptor %d", outputFd) + parcTrapUnexpectedStateIf(charactersPrinted < 0, "Cannot write to file descriptor %d", outputFd) { pthread_mutex_unlock(&head_mutex); } @@ -394,7 +394,7 @@ _parcSafeMemory_Destroy(void **memoryPointer) PARCSafeMemoryUsable *memory = *memoryPointer; PARCSafeMemoryState state = _parcSafeMemory_GetState(memory); - trapUnexpectedStateIf(state != PARCSafeMemoryState_OK, + parcTrapUnexpectedStateIf(state != PARCSafeMemoryState_OK, "Expected PARCSafeMemoryState_OK, actual %s (see parc_SafeMemory.h)", _parcSafeMemory_StateToString(state)) { @@ -474,7 +474,7 @@ _parcSafeMemory_FormatPrefix(PARCSafeMemoryOrigin *origin, size_t requestedLengt PARCSafeMemoryUsable *result = _pointerAdd(origin, prefixSize); - assertAligned(result, alignment, "Return value is not properly aligned to %zu", alignment); + parcAssertAligned(result, alignment, "Return value is not properly aligned to %zu", alignment); return result; } diff --git a/libparc/parc/algol/parc_SafeMemory.h b/libparc/parc/algol/parc_SafeMemory.h index 0383fe39..a2574e87 100644 --- a/libparc/parc/algol/parc_SafeMemory.h +++ b/libparc/parc/algol/parc_SafeMemory.h @@ -209,7 +209,7 @@ void parcSafeMemory_Deallocate(void **pointer); * size_t newLength = 0; * unsigned char *newMemory = parcSafeMemory_Reallocate(memory, newLength); * - * assertTrue(newMemory == NULL, "Expected NULL, actual %p", newMemory); + * parcAssertTrue(newMemory == NULL, "Expected NULL, actual %p", newMemory); * } * @endcode */ diff --git a/libparc/parc/algol/parc_SortedList.c b/libparc/parc/algol/parc_SortedList.c index 8a941701..1efa25ea 100644 --- a/libparc/parc/algol/parc_SortedList.c +++ b/libparc/parc/algol/parc_SortedList.c @@ -32,7 +32,7 @@ struct PARCSortedList { static void _parcSortedList_Finalize(PARCSortedList **instancePtr) { - assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSortedList pointer."); + parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCSortedList pointer."); PARCSortedList *instance = *instancePtr; parcSortedList_OptionalAssertValid(instance); @@ -50,7 +50,7 @@ parcObject_ExtendPARCObject(PARCSortedList, _parcSortedList_Finalize, parcSorted void parcSortedList_AssertValid(const PARCSortedList *instance) { - assertTrue(parcSortedList_IsValid(instance), + parcAssertTrue(parcSortedList_IsValid(instance), "PARCSortedList is not valid."); } @@ -245,7 +245,7 @@ void parcSortedList_Add(PARCSortedList *instance, PARCObject *element) { size_t insertionPoint = _parcSortedList_GetInsertionIndex(instance, element); - assertTrue(insertionPoint >= 0 && insertionPoint <= parcLinkedList_Size(instance->list), + parcAssertTrue(insertionPoint >= 0 && insertionPoint <= parcLinkedList_Size(instance->list), "%zd is bad insertion point. Must be >=0 and <= %zd", insertionPoint, parcLinkedList_Size(instance->list)); parcLinkedList_InsertAtIndex(instance->list, insertionPoint, element); diff --git a/libparc/parc/algol/parc_Stack.c b/libparc/parc/algol/parc_Stack.c index 5930169b..72cae53c 100755 --- a/libparc/parc/algol/parc_Stack.c +++ b/libparc/parc/algol/parc_Stack.c @@ -19,7 +19,7 @@ #include -#include +#include #include #include @@ -34,7 +34,7 @@ PARCStack * parcStack(void *instance, PARCStackInterface *interface) { PARCStack *result = parcMemory_AllocateAndClear(sizeof(PARCStack)); - assertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCStack)); + parcAssertNotNull(result, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCStack)); result->instance = instance; result->interface = interface; diff --git a/libparc/parc/algol/parc_StdlibMemory.c b/libparc/parc/algol/parc_StdlibMemory.c index a919f727..11381a54 100755 --- a/libparc/parc/algol/parc_StdlibMemory.c +++ b/libparc/parc/algol/parc_StdlibMemory.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include @@ -132,7 +132,7 @@ void parcStdlibMemory_Deallocate(void **pointer) { #ifndef PARCLibrary_DISABLE_VALIDATION - trapIllegalValueIf(_parcStdlibMemory_OutstandingAllocations == 0, + parcTrapIllegalValueIf(_parcStdlibMemory_OutstandingAllocations == 0, "parcStdlibMemory_Deallocate invoked with nothing left to free (double free somewhere?)\n"); #endif free(*pointer); diff --git a/libparc/parc/algol/parc_String.c b/libparc/parc/algol/parc_String.c index e5af5f71..78aaf470 100755 --- a/libparc/parc/algol/parc_String.c +++ b/libparc/parc/algol/parc_String.c @@ -30,7 +30,7 @@ struct PARCString { static bool _parcString_Destructor(PARCString **instancePtr) { - assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCString pointer."); + parcAssertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCString pointer."); PARCString *string = *instancePtr; parcMemory_Deallocate(&string->string); @@ -55,7 +55,7 @@ parcObject_Override(PARCString, PARCObject, void parcString_AssertValid(const PARCString *instance) { - assertTrue(parcString_IsValid(instance), + parcAssertTrue(parcString_IsValid(instance), "PARCString is not valid."); } diff --git a/libparc/parc/algol/parc_Time.c b/libparc/parc/algol/parc_Time.c index 7cc358b9..07ab185b 100755 --- a/libparc/parc/algol/parc_Time.c +++ b/libparc/parc/algol/parc_Time.c @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -32,7 +32,7 @@ parcTime_TimevalAsString(struct timeval timeval) { char *string; int nwritten = asprintf(&string, "%ld.%06ld", timeval.tv_sec, (long) timeval.tv_usec); - assertTrue(nwritten >= 0, "Error calling asprintf"); + parcAssertTrue(nwritten >= 0, "Error calling asprintf"); char *result = parcMemory_StringDuplicate(string, strlen(string)); free(string); diff --git a/libparc/parc/algol/parc_TreeMap.c b/libparc/parc/algol/parc_TreeMap.c index 9c776b30..9922829b 100755 --- a/libparc/parc/algol/parc_TreeMap.c +++ b/libparc/parc/algol/parc_TreeMap.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include @@ -167,7 +167,7 @@ static _RBNode * _rbNodeCreate(PARCTreeMap *tree, int color) { _RBNode *node = parcMemory_AllocateAndClear(sizeof(_RBNode)); - assertNotNull(node, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(_RBNode)); + parcAssertNotNull(node, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(_RBNode)); node->color = color; node->leftChild = tree->nil; node->rightChild = tree->nil; @@ -353,28 +353,28 @@ static void _rbNodeAssertNodeInvariants(_RBNode *node, PARCObject *data) { PARCTreeMap *tree = (PARCTreeMap *) data; - assertNotNull(node->parent, "Node has NULL parent"); - assertNotNull(node->leftChild, "Left child NULL"); - assertNotNull(node->rightChild, "Richt child NULL"); + parcAssertNotNull(node->parent, "Node has NULL parent"); + parcAssertNotNull(node->leftChild, "Left child NULL"); + parcAssertNotNull(node->rightChild, "Richt child NULL"); if (node != tree->root) { - assertTrue(node->parent != tree->nil, "Paren't can't be nill for node!"); + parcAssertTrue(node->parent != tree->nil, "Paren't can't be nill for node!"); // Don't need to compare to parent, they compared to us } - assertNotNull(node->element, "We have a null element!!"); - assertNotNull(parcKeyValue_GetKey(node->element), "We have a null key!!"); - assertNotNull(parcKeyValue_GetValue(node->element), "We have a null value!!"); + parcAssertNotNull(node->element, "We have a null element!!"); + parcAssertNotNull(parcKeyValue_GetKey(node->element), "We have a null key!!"); + parcAssertNotNull(parcKeyValue_GetValue(node->element), "We have a null value!!"); if (node->leftChild != tree->nil) { if (tree->customCompare != NULL) { - assertTrue(tree->customCompare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->leftChild->element)) > 0, "Left child not smaller?"); + parcAssertTrue(tree->customCompare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->leftChild->element)) > 0, "Left child not smaller?"); } else { - assertTrue(parcObject_Compare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->leftChild->element)) > 0, "Left child not smaller?"); + parcAssertTrue(parcObject_Compare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->leftChild->element)) > 0, "Left child not smaller?"); } } if (node->rightChild != tree->nil) { if (tree->customCompare != NULL) { - assertTrue(tree->customCompare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->rightChild->element)) < 0, "Right child not bigger?"); + parcAssertTrue(tree->customCompare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->rightChild->element)) < 0, "Right child not bigger?"); } else { - assertTrue(parcObject_Compare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->rightChild->element)) < 0, "Right child not bigger?"); + parcAssertTrue(parcObject_Compare(parcKeyValue_GetKey(node->element), parcKeyValue_GetKey(node->rightChild->element)) < 0, "Right child not bigger?"); } } } @@ -383,11 +383,11 @@ static void _rbNodeAssertTreeInvariants(const PARCTreeMap *tree) { - assertNotNull(tree, "Tree is null!"); - assertTrue(tree->size >= 0, "Tree has negative size"); + parcAssertNotNull(tree, "Tree is null!"); + parcAssertTrue(tree->size >= 0, "Tree has negative size"); if (tree->size != 0) { - assertTrue(tree->root != tree->nil, "Tree size = %d > 0 but root is nil", tree->size); - assertNotNull(tree->root, "Tree size > 0 but root is NULL"); + parcAssertTrue(tree->root != tree->nil, "Tree size = %d > 0 but root is nil", tree->size); + parcAssertNotNull(tree->root, "Tree size > 0 but root is NULL"); #ifdef ASSERT_INVARIANTS _rbNodeRecursiveRun((PARCTreeMap *) tree, tree->root, _rbNodeAssertNodeInvariants, (PARCObject *) tree); #endif @@ -558,8 +558,8 @@ _rbNodeRemove(PARCTreeMap *tree, _RBNode *node) static void _parcTreeMap_Destroy(PARCTreeMap **treePointer) { - assertNotNull(treePointer, "pointer to pointer to tree can't be null"); - assertNotNull(*treePointer, "pointer to tree can't be null"); + parcAssertNotNull(treePointer, "pointer to pointer to tree can't be null"); + parcAssertNotNull(*treePointer, "pointer to tree can't be null"); _rbNodeAssertTreeInvariants(*treePointer); if ((*treePointer)->size > 0) { @@ -582,7 +582,7 @@ PARCTreeMap * parcTreeMap_CreateCustom(PARCTreeMap_CustomCompare *customCompare) { PARCTreeMap *tree = parcObject_CreateInstance(PARCTreeMap); - assertNotNull(tree, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCTreeMap)); + parcAssertNotNull(tree, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCTreeMap)); tree->nil = _rbNodeCreate(tree, BLACK); tree->nil->leftChild = tree->nil; tree->nil->rightChild = tree->nil; @@ -602,9 +602,9 @@ parcTreeMap_Create(void) void parcTreeMap_Put(PARCTreeMap *tree, const PARCObject *key, const PARCObject *value) { - assertNotNull(tree, "Tree can't be NULL"); - assertNotNull(key, "Key can't be NULL"); - assertNotNull(value, "Value can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(key, "Key can't be NULL"); + parcAssertNotNull(value, "Value can't be NULL"); _RBNode *newNode = _rbNodeCreate(tree, RED); _RBNode *parent = tree->nil; @@ -660,7 +660,7 @@ parcTreeMap_Put(PARCTreeMap *tree, const PARCObject *key, const PARCObject *valu PARCObject * parcTreeMap_Get(PARCTreeMap *tree, const PARCObject *key) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); _rbNodeAssertTreeInvariants(tree); PARCObject *result = NULL; @@ -678,8 +678,8 @@ parcTreeMap_Get(PARCTreeMap *tree, const PARCObject *key) PARCObject * parcTreeMap_Remove(PARCTreeMap *tree, const PARCObject *key) { - assertNotNull(tree, "Tree can't be NULL"); - assertNotNull(key, "Key can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(key, "Key can't be NULL"); _rbNodeAssertTreeInvariants(tree); PARCObject *result = NULL; @@ -703,8 +703,8 @@ parcTreeMap_Remove(PARCTreeMap *tree, const PARCObject *key) void parcTreeMap_RemoveAndRelease(PARCTreeMap *tree, const PARCObject *key) { - assertNotNull(tree, "Tree can't be NULL"); - assertNotNull(key, "Key can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(key, "Key can't be NULL"); _RBNode *node = _rbFindNode(tree, tree->root, key); @@ -719,7 +719,7 @@ parcTreeMap_RemoveAndRelease(PARCTreeMap *tree, const PARCObject *key) PARCKeyValue * parcTreeMap_GetLastEntry(const PARCTreeMap *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); _rbNodeAssertTreeInvariants(tree); _RBNode *node = tree->root; @@ -752,7 +752,7 @@ parcTreeMap_GetLastKey(const PARCTreeMap *tree) PARCKeyValue * parcTreeMap_GetFirstEntry(const PARCTreeMap *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); _rbNodeAssertTreeInvariants(tree); if (tree->size == 0) { @@ -840,7 +840,7 @@ parcTreeMap_GetLowerKey(const PARCTreeMap *tree, const PARCObject *key) size_t parcTreeMap_Size(const PARCTreeMap *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); _rbNodeAssertTreeInvariants(tree); return tree->size; @@ -867,7 +867,7 @@ _rbAddElementToList(_RBNode *node, PARCList *list) PARCList * parcTreeMap_AcquireKeys(const PARCTreeMap *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); _rbNodeAssertTreeInvariants(tree); PARCList *keys = parcList(parcArrayList_Create_Capacity((bool (*)(void *x, void *y))parcObject_Equals, @@ -883,7 +883,7 @@ parcTreeMap_AcquireKeys(const PARCTreeMap *tree) PARCList * parcTreeMap_AcquireValues(const PARCTreeMap *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); _rbNodeAssertTreeInvariants(tree); PARCList *values = parcList(parcArrayList_Create_Capacity((bool (*)(void *x, void *y))parcObject_Equals, @@ -899,7 +899,7 @@ parcTreeMap_AcquireValues(const PARCTreeMap *tree) static PARCList * _parcTreeMap_Elements(const PARCTreeMap *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); _rbNodeAssertTreeInvariants(tree); PARCList *elements = parcList(parcArrayList_Create_Capacity((bool (*)(void *x, void *y))parcObject_Equals, @@ -917,8 +917,8 @@ parcTreeMap_Equals(const PARCTreeMap *tree1, const PARCTreeMap *tree2) { _rbNodeAssertTreeInvariants(tree1); _rbNodeAssertTreeInvariants(tree2); - assertNotNull(tree1, "Tree can't be NULL"); - assertNotNull(tree2, "Tree can't be NULL"); + parcAssertNotNull(tree1, "Tree can't be NULL"); + parcAssertNotNull(tree2, "Tree can't be NULL"); bool result = false; @@ -968,7 +968,7 @@ PARCTreeMap * parcTreeMap_Copy(const PARCTreeMap *sourceTree) { _rbNodeAssertTreeInvariants(sourceTree); - assertNotNull(sourceTree, "Tree can't be NULL"); + parcAssertNotNull(sourceTree, "Tree can't be NULL"); PARCObject *keySource; PARCObject *keyCopy; @@ -1019,7 +1019,7 @@ _parcTreeMapIterator_Init(PARCTreeMap *map) state->list = _parcTreeMap_Elements(map); state->currentIndex = 0; state->currentElement = parcList_GetAtIndex(state->list, 0); - trapOutOfMemoryIf(state->list == NULL, "Cannot create parcList"); + parcTrapOutOfMemoryIf(state->list == NULL, "Cannot create parcList"); } return state; diff --git a/libparc/parc/algol/parc_TreeRedBlack.c b/libparc/parc/algol/parc_TreeRedBlack.c index 2d772555..71a23f10 100755 --- a/libparc/parc/algol/parc_TreeRedBlack.c +++ b/libparc/parc/algol/parc_TreeRedBlack.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include @@ -102,7 +102,7 @@ static Node * _rbNodeCreate(PARCTreeRedBlack *tree, int color) { Node *node = parcMemory_AllocateAndClear(sizeof(Node)); - assertNotNull(node, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(Node)); + parcAssertNotNull(node, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(Node)); node->color = color; node->left_child = tree->nil; node->right_child = tree->nil; @@ -414,9 +414,9 @@ parcTreeRedBlack_Create(PARCTreeRedBlack_KeyCompare *keyCompare, PARCTreeRedBlack_ValueFree *valueFree, PARCTreeRedBlack_ValueCopy *valueCopy) { - assertNotNull(keyCompare, "We need a key compare function"); + parcAssertNotNull(keyCompare, "We need a key compare function"); PARCTreeRedBlack *tree = parcMemory_AllocateAndClear(sizeof(PARCTreeRedBlack)); - assertNotNull(tree, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCTreeRedBlack)); + parcAssertNotNull(tree, "parcMemory_AllocateAndClear(%zu) returned NULL", sizeof(PARCTreeRedBlack)); tree->nil = _rbNodeCreate(tree, BLACK); tree->nil->left_child = tree->nil; tree->nil->right_child = tree->nil; @@ -435,8 +435,8 @@ parcTreeRedBlack_Create(PARCTreeRedBlack_KeyCompare *keyCompare, void parcTreeRedBlack_Destroy(PARCTreeRedBlack **treePointer) { - assertNotNull(treePointer, "pointer to pointer to tree can't be null"); - assertNotNull(*treePointer, "pointer to tree can't be null"); + parcAssertNotNull(treePointer, "pointer to pointer to tree can't be null"); + parcAssertNotNull(*treePointer, "pointer to tree can't be null"); if ((*treePointer)->size > 0) { // If we have any elements in the tree, free them @@ -453,9 +453,9 @@ parcTreeRedBlack_Destroy(PARCTreeRedBlack **treePointer) void parcTreeRedBlack_Insert(PARCTreeRedBlack *tree, void *key, void *value) { - assertNotNull(tree, "Tree can't be NULL"); - assertNotNull(key, "Key can't be NULL"); - assertNotNull(value, "Value can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(key, "Key can't be NULL"); + parcAssertNotNull(value, "Value can't be NULL"); Node *newNode = _rbNodeCreate(tree, RED); Node *parent = tree->nil; @@ -511,7 +511,7 @@ parcTreeRedBlack_Insert(PARCTreeRedBlack *tree, void *key, void *value) void * parcTreeRedBlack_Get(PARCTreeRedBlack *tree, const void *key) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); Node *node = tree->root; @@ -535,8 +535,8 @@ parcTreeRedBlack_Get(PARCTreeRedBlack *tree, const void *key) void * parcTreeRedBlack_Remove(PARCTreeRedBlack *tree, const void *key) { - assertNotNull(tree, "Tree can't be NULL"); - assertNotNull(key, "Key can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(key, "Key can't be NULL"); Node *node = tree->root; @@ -568,8 +568,8 @@ parcTreeRedBlack_Remove(PARCTreeRedBlack *tree, const void *key) void parcTreeRedBlack_RemoveAndDestroy(PARCTreeRedBlack *tree, const void *key) { - assertNotNull(tree, "Tree can't be NULL"); - assertNotNull(key, "Key can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(key, "Key can't be NULL"); Node *node = tree->root; // Let's get to the bottom of the tree to insert. @@ -591,7 +591,7 @@ parcTreeRedBlack_RemoveAndDestroy(PARCTreeRedBlack *tree, const void *key) void * parcTreeRedBlack_LastKey(const PARCTreeRedBlack *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); Node *node = tree->root; if (tree->size == 0) { @@ -610,7 +610,7 @@ parcTreeRedBlack_LastKey(const PARCTreeRedBlack *tree) void * parcTreeRedBlack_FirstKey(const PARCTreeRedBlack *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); Node *node = tree->root; @@ -630,7 +630,7 @@ parcTreeRedBlack_FirstKey(const PARCTreeRedBlack *tree) size_t parcTreeRedBlack_Size(const PARCTreeRedBlack *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); return tree->size; } @@ -645,7 +645,7 @@ _rbGetKeys(Node *node, void *data) PARCArrayList * parcTreeRedBlack_Keys(const PARCTreeRedBlack *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); PARCArrayList *keys = parcArrayList_Create(NULL); @@ -665,7 +665,7 @@ _rbGetValues(Node *node, void *data) PARCArrayList * parcTreeRedBlack_Values(const PARCTreeRedBlack *tree) { - assertNotNull(tree, "Tree can't be NULL"); + parcAssertNotNull(tree, "Tree can't be NULL"); PARCArrayList *values = parcArrayList_Create(NULL); @@ -678,8 +678,8 @@ parcTreeRedBlack_Values(const PARCTreeRedBlack *tree) int parcTreeRedBlack_Equals(const PARCTreeRedBlack *tree1, const PARCTreeRedBlack *tree2) { - assertNotNull(tree1, "Tree can't be NULL"); - assertNotNull(tree2, "Tree can't be NULL"); + parcAssertNotNull(tree1, "Tree can't be NULL"); + parcAssertNotNull(tree2, "Tree can't be NULL"); int ret = 1; @@ -736,7 +736,7 @@ parcTreeRedBlack_Equals(const PARCTreeRedBlack *tree1, const PARCTreeRedBlack *t PARCTreeRedBlack * parcTreeRedBlack_Copy(const PARCTreeRedBlack *source_tree) { - assertNotNull(source_tree, "Tree can't be NULL"); + parcAssertNotNull(source_tree, "Tree can't be NULL"); void *key_source; void *key_copy; diff --git a/libparc/parc/algol/parc_URI.c b/libparc/parc/algol/parc_URI.c index 172468d8..e14dfc9f 100644 --- a/libparc/parc/algol/parc_URI.c +++ b/libparc/parc/algol/parc_URI.c @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include @@ -61,7 +61,7 @@ struct parc_uri { static void _parcURI_Finalize(PARCURI **uriPtr) { - assertNotNull(uriPtr, "Parameter must be a non-null pointer to a pointer to a PARCURI instance."); + parcAssertNotNull(uriPtr, "Parameter must be a non-null pointer to a pointer to a PARCURI instance."); PARCURI *uri = *uriPtr; diff --git a/libparc/parc/algol/parc_URIAuthority.c b/libparc/parc/algol/parc_URIAuthority.c index ac2ee351..1e3468d1 100644 --- a/libparc/parc/algol/parc_URIAuthority.c +++ b/libparc/parc/algol/parc_URIAuthority.c @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include diff --git a/libparc/parc/algol/parc_URIPath.c b/libparc/parc/algol/parc_URIPath.c index ef46dac9..04636852 100755 --- a/libparc/parc/algol/parc_URIPath.c +++ b/libparc/parc/algol/parc_URIPath.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -40,7 +40,7 @@ struct parc_uri_path { static void _parcURIPath_Finalize(PARCURIPath **pathPtr) { - assertNotNull(pathPtr, "Parameter must be a non-null pointer to a pointer to a PARCURIPath instance."); + parcAssertNotNull(pathPtr, "Parameter must be a non-null pointer to a pointer to a PARCURIPath instance."); PARCURIPath *path = *pathPtr; if (path != NULL) { @@ -89,7 +89,7 @@ parcURIPath_Trim(PARCURIPath *path, size_t numberToRemove) // // result->segments = parcArrayList_Create((void (*)(void **))parcURISegment_Release); // if (*string != 0) { -// assertTrue(*string == '/', "Expected initial '/' character."); +// parcAssertTrue(*string == '/', "Expected initial '/' character."); // *pointer = string; // while (**pointer != 0 && **pointer != '?' && **pointer != '#') { // PARCURISegment *segment = parcURISegment_Parse(++(*pointer), pointer); @@ -148,7 +148,7 @@ parcURIPath_Equals(const PARCURIPath *pathA, const PARCURIPath *pathB) PARCURIPath * parcURIPath_Copy(const PARCURIPath *path) { - assertNotNull(path, "Parameter must be a non-null PARC_URIPath pointer."); + parcAssertNotNull(path, "Parameter must be a non-null PARC_URIPath pointer."); PARCURIPath *result = parcURIPath_Create(); result->segments = parcArrayList_Create((void (*)(void **))parcURISegment_Release); diff --git a/libparc/parc/algol/parc_URIPath.h b/libparc/parc/algol/parc_URIPath.h index d43d8651..4e2d62e5 100755 --- a/libparc/parc/algol/parc_URIPath.h +++ b/libparc/parc/algol/parc_URIPath.h @@ -332,7 +332,7 @@ PARCURIPath *parcURIPath_Append(PARCURIPath *path, const PARCURISegment *segment * Retrieve the URI path segment at the specified index. * * The index must be within the range [0, number of segments] - * prior to invocation. Otherwise, the program is terminated with LongBow trapOutOfBounds. + * prior to invocation. Otherwise, the program is terminated with parcTrapOutOfBounds. * * @param [in] path A `PARCURIPath` instance to be examined. * @param [in] index The index of the URI segment to retrieve. diff --git a/libparc/parc/algol/parc_URISegment.c b/libparc/parc/algol/parc_URISegment.c index 7261c3aa..786a7182 100755 --- a/libparc/parc/algol/parc_URISegment.c +++ b/libparc/parc/algol/parc_URISegment.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -93,7 +93,7 @@ _parsePercentEncoded(const char *string, unsigned char *value) static PARCBufferComposer * _parcURISegment_BuildString(const PARCURISegment *segment, PARCBufferComposer *composer) { - assertNotNull(composer, "Parameter must be a non-null pointer to a PARCBufferComposer."); + parcAssertNotNull(composer, "Parameter must be a non-null pointer to a PARCBufferComposer."); for (size_t i = 0; i < parcBuffer_Limit(segment->buffer) && composer != NULL; i++) { unsigned char c = parcBuffer_GetAtIndex(segment->buffer, i); @@ -148,10 +148,10 @@ parcURISegment_Create(size_t length, const unsigned char segment[length]) PARCURISegment * parcURISegment_Parse(const char *string, const char **pointer) { - assertFalse(*string == '/', "Input parameter '%s' must NOT point to an initial '/' character.", string); + parcAssertFalse(*string == '/', "Input parameter '%s' must NOT point to an initial '/' character.", string); unsigned char *segment = parcMemory_AllocateAndClear((strlen(string) + 1) * sizeof(unsigned char)); - assertNotNull(segment, "parcMemory_AllocateAndClear(%zu) returned NULL", (strlen(string) + 1) * sizeof(unsigned char)); + parcAssertNotNull(segment, "parcMemory_AllocateAndClear(%zu) returned NULL", (strlen(string) + 1) * sizeof(unsigned char)); size_t length = 0; unsigned char *r = segment; @@ -219,7 +219,7 @@ parcURISegment_Equals(const PARCURISegment *segmentA, const PARCURISegment *segm PARCURISegment * parcURISegment_Clone(const PARCURISegment *segment) { - assertNotNull(segment, "Parameter must be a non-null PARC_URISegment pointer."); + parcAssertNotNull(segment, "Parameter must be a non-null PARC_URISegment pointer."); PARCBuffer *copy = parcBuffer_Copy(segment->buffer); PARCURISegment *result = parcURISegment_CreateFromBuffer(copy); diff --git a/libparc/parc/algol/parc_Unsigned.c b/libparc/parc/algol/parc_Unsigned.c index 839f6b2b..a8fd1053 100644 --- a/libparc/parc/algol/parc_Unsigned.c +++ b/libparc/parc/algol/parc_Unsigned.c @@ -52,7 +52,7 @@ parcObject_Override(PARCUnsigned, PARCObject, void parcUnsigned_AssertValid(const PARCUnsigned *instance) { - assertTrue(parcUnsigned_IsValid(instance), + parcAssertTrue(parcUnsigned_IsValid(instance), "PARCUnsigned is not valid."); } diff --git a/libparc/parc/algol/parc_Varint.c b/libparc/parc/algol/parc_Varint.c index 7a593f45..7a1d2698 100755 --- a/libparc/parc/algol/parc_Varint.c +++ b/libparc/parc/algol/parc_Varint.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -45,12 +45,12 @@ parcVarint_Create(void) PARCVarint * parcVarint_DecodeBuffer(PARCBuffer *buffer, size_t length) { - assertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer."); - assertTrue(length < sizeof(size_t), "Length must be less then or equal to %zd", sizeof(size_t)); - assertTrue(length <= parcBuffer_Remaining(buffer), "Buffer does not contain at least %zd bytes", length); + parcAssertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer."); + parcAssertTrue(length < sizeof(size_t), "Length must be less then or equal to %zd", sizeof(size_t)); + parcAssertTrue(length <= parcBuffer_Remaining(buffer), "Buffer does not contain at least %zd bytes", length); PARCVarint *result = parcVarint_Create(); - assertNotNull(result, "PARCVarint out of memory."); + parcAssertNotNull(result, "PARCVarint out of memory."); for (size_t i = 0; i < length; i++) { parcVarint_ShiftLeft(result, 8); @@ -63,11 +63,11 @@ parcVarint_DecodeBuffer(PARCBuffer *buffer, size_t length) PARCVarint * parcVarint_DecodeElasticByteBuffer(const PARCBuffer *buffer, size_t length) { - assertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer."); - assertTrue(length < sizeof(size_t), "Length must be less then or equal to %zd", sizeof(size_t)); + parcAssertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer."); + parcAssertTrue(length < sizeof(size_t), "Length must be less then or equal to %zd", sizeof(size_t)); PARCVarint *result = parcVarint_Create(); - assertNotNull(result, "PARCVarint out of memory."); + parcAssertNotNull(result, "PARCVarint out of memory."); for (size_t i = 0; i < length; i++) { parcVarint_ShiftLeft(result, 8); @@ -87,7 +87,7 @@ parcVarint_Set(PARCVarint *varint, uint64_t newValue) PARCVarint * parcVarint_FromElasticByteBuffer(const PARCBuffer *buffer) { - assertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer."); + parcAssertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer."); PARCVarint *result = parcVarint_Create(); size_t length = parcBuffer_Remaining(buffer); @@ -103,7 +103,7 @@ parcVarint_FromElasticByteBuffer(const PARCBuffer *buffer) PARCVarint * parcVarint_FromUTF8ByteBuffer(const PARCBuffer *buffer) { - assertNotNull(buffer, "Parameter must not be NULL."); + parcAssertNotNull(buffer, "Parameter must not be NULL."); PARCVarint *result = parcVarint_Create(); if (result != NULL) { @@ -121,7 +121,7 @@ parcVarint_FromUTF8ByteBuffer(const PARCBuffer *buffer) PARCVarint * parcVarint_FromUTF8Buffer(PARCBuffer *buffer) { - assertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer."); + parcAssertNotNull(buffer, "Parameter must be a non-null PARCBuffer pointer."); PARCVarint *result = parcVarint_Create(); if (result != NULL) { @@ -180,8 +180,8 @@ parcVarint_FromUint64(uint64_t uint) void parcVarint_Destroy(PARCVarint **varintP) { - assertNotNull(varintP, "Parameter must be a non-null pointer to a pointer to a PARCVarint"); - assertNotNull(*varintP, "Parameter must be a non-null pointer to a PARCVarint"); + parcAssertNotNull(varintP, "Parameter must be a non-null pointer to a pointer to a PARCVarint"); + parcAssertNotNull(*varintP, "Parameter must be a non-null pointer to a PARCVarint"); parcMemory_Deallocate((void **) varintP); *varintP = NULL; @@ -197,7 +197,7 @@ parcVarint_Destroy(PARCVarint **varintP) PARCVarint * parcVarint_ShiftLeft(PARCVarint *varint, int bits) { - assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); + parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); varint->value <<= bits; return varint; @@ -206,7 +206,7 @@ parcVarint_ShiftLeft(PARCVarint *varint, int bits) PARCVarint * parcVarint_Add(PARCVarint *varint, int addend) { - assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); + parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); varint->value += addend; return varint; @@ -215,7 +215,7 @@ parcVarint_Add(PARCVarint *varint, int addend) PARCVarint * parcVarint_Subtract(PARCVarint *varint, int subtrahend) { - assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); + parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); varint->value -= subtrahend; return varint; @@ -224,7 +224,7 @@ parcVarint_Subtract(PARCVarint *varint, int subtrahend) PARCVarint * parcVarint_Multiply(PARCVarint *varint, int multiplicand) { - assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); + parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); varint->value *= multiplicand; return varint; @@ -233,7 +233,7 @@ parcVarint_Multiply(PARCVarint *varint, int multiplicand) PARCVarint * parcVarint_Divide(PARCVarint *varint, int divisor) { - assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); + parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); varint->value /= divisor; return varint; @@ -249,7 +249,7 @@ parcVarint_Divide(PARCVarint *varint, int divisor) PARCVarint * parcVarint_ShiftRight(PARCVarint *varint, int bits) { - assertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); + parcAssertNotNull(varint, "Parameter must be a non-null pointer to a PARCVarint."); varint->value >>= bits; return varint; } @@ -265,8 +265,8 @@ parcVarint_ShiftRight(PARCVarint *varint, int bits) PARCVarint * parcVarint_And(PARCVarint *varint, PARCVarint *operand) { - assertNotNull(varint, "Parameter varint must not be NULL."); - assertNotNull(operand, "Parameter operand must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(operand, "Parameter operand must not be NULL."); varint->value &= operand->value; return varint; } @@ -280,7 +280,7 @@ parcVarint_And(PARCVarint *varint, PARCVarint *operand) PARCVarint * parcVarint_AndUint8(PARCVarint *varint, uint8_t operand) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); varint->value &= operand; return varint; } @@ -294,7 +294,7 @@ parcVarint_AndUint8(PARCVarint *varint, uint8_t operand) PARCVarint * parcVarint_AndUint16(PARCVarint *varint, uint16_t operand) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); varint->value &= operand; return varint; } @@ -308,7 +308,7 @@ parcVarint_AndUint16(PARCVarint *varint, uint16_t operand) PARCVarint * parcVarint_AndUint32(PARCVarint *varint, uint32_t operand) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); varint->value &= operand; return varint; } @@ -322,7 +322,7 @@ parcVarint_AndUint32(PARCVarint *varint, uint32_t operand) PARCVarint * parcVarint_AndUint64(PARCVarint *varint, uint64_t operand) { - assertNotNull(varint, "Parameter must be a non-null PARCVarint pointer."); + parcAssertNotNull(varint, "Parameter must be a non-null PARCVarint pointer."); varint->value &= operand; return varint; } @@ -336,7 +336,7 @@ parcVarint_AndUint64(PARCVarint *varint, uint64_t operand) PARCVarint * parcVarint_Or(PARCVarint *varint, PARCVarint *operand) { - assertNotNull(varint, "Parameter must be a non-null PARCVarint pointer."); + parcAssertNotNull(varint, "Parameter must be a non-null PARCVarint pointer."); varint->value |= operand->value; return varint; } @@ -351,7 +351,7 @@ parcVarint_Or(PARCVarint *varint, PARCVarint *operand) PARCVarint * parcVarint_OrUint8(PARCVarint *varint, uint8_t operand) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); varint->value |= operand; return varint; } @@ -366,7 +366,7 @@ parcVarint_OrUint8(PARCVarint *varint, uint8_t operand) PARCVarint * parcVarint_OrUint16(PARCVarint *varint, uint16_t operand) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); varint->value |= operand; return varint; } @@ -381,7 +381,7 @@ parcVarint_OrUint16(PARCVarint *varint, uint16_t operand) PARCVarint * parcVarint_OrUint32(PARCVarint *varint, uint32_t operand) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); varint->value |= operand; return varint; } @@ -396,7 +396,7 @@ parcVarint_OrUint32(PARCVarint *varint, uint32_t operand) PARCVarint * parcVarint_OrUint64(PARCVarint *varint, uint64_t operand) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); varint->value |= operand; return varint; } @@ -411,7 +411,7 @@ parcVarint_OrUint64(PARCVarint *varint, uint64_t operand) int parcVarint_Equals(PARCVarint *varint, PARCVarint *operand) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); return varint->value == operand->value; } @@ -424,7 +424,7 @@ parcVarint_Equals(PARCVarint *varint, PARCVarint *operand) int parcVarint_EqualsUint64(PARCVarint *varint, uint64_t value) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); return varint->value == value; } @@ -437,7 +437,7 @@ parcVarint_EqualsUint64(PARCVarint *varint, uint64_t value) int parcVarint_EqualsUint32(PARCVarint *varint, uint32_t value) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); return parcVarint_EqualsUint64(varint, (uint64_t) value); } @@ -450,7 +450,7 @@ parcVarint_EqualsUint32(PARCVarint *varint, uint32_t value) int parcVarint_EqualsUint16(PARCVarint *varint, uint16_t value) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); return parcVarint_EqualsUint64(varint, (uint64_t) value); } @@ -463,7 +463,7 @@ parcVarint_EqualsUint16(PARCVarint *varint, uint16_t value) int parcVarint_EqualsUint8(PARCVarint *varint, uint8_t value) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); return parcVarint_EqualsUint64(varint, (uint64_t) value); } @@ -476,7 +476,7 @@ parcVarint_EqualsUint8(PARCVarint *varint, uint8_t value) uint8_t parcVarint_AsUint8(const PARCVarint *varint) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); return (uint8_t) varint->value; } @@ -489,7 +489,7 @@ parcVarint_AsUint8(const PARCVarint *varint) uint16_t parcVarint_AsUint16(const PARCVarint *varint) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); return (uint16_t) varint->value; } @@ -502,14 +502,14 @@ parcVarint_AsUint16(const PARCVarint *varint) uint32_t parcVarint_AsUint32(const PARCVarint *varint) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); return (uint32_t) varint->value; } uint64_t parcVarint_AsUint64(const PARCVarint *varint) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); return varint->value; } @@ -522,7 +522,7 @@ parcVarint_AsUint64(const PARCVarint *varint) size_t parcVarint_AsSize(const PARCVarint *varint) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); return (size_t) varint->value; } @@ -536,8 +536,8 @@ parcVarint_AsSize(const PARCVarint *varint) char * parcVarint_ToString(char **string, PARCVarint *varint) { - assertNotNull(varint, "Parameter varint must not be NULL."); + parcAssertNotNull(varint, "Parameter varint must not be NULL."); int nwritten = asprintf(string, "%" PRIu64, varint->value); - assertTrue(nwritten >= 0, "Error calling asprintf"); + parcAssertTrue(nwritten >= 0, "Error calling asprintf"); return *string; } diff --git a/libparc/parc/algol/parc_Vector.c b/libparc/parc/algol/parc_Vector.c index f5380eb7..1d0e9a1d 100755 --- a/libparc/parc/algol/parc_Vector.c +++ b/libparc/parc/algol/parc_Vector.c @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include @@ -46,7 +46,7 @@ parcVector_Create(const void *pointer, const size_t length) PARCVector * parcVector_Init(PARCVector *vector, const void *pointer, const size_t length) { - assertNotNull(vector, "Parameter must be a non-null PARCVector pointer"); + parcAssertNotNull(vector, "Parameter must be a non-null PARCVector pointer"); vector->pointer = pointer; vector->length = length; @@ -56,9 +56,9 @@ parcVector_Init(PARCVector *vector, const void *pointer, const size_t length) void parcVector_Destroy(PARCVector **vectorPtr) { - assertNotNull(vectorPtr, "Parameter must be a non-null PARCVector pointer"); + parcAssertNotNull(vectorPtr, "Parameter must be a non-null PARCVector pointer"); PARCVector *vector = *vectorPtr; - assertNotNull(vector, "Vector is already free or was not set.\n"); + parcAssertNotNull(vector, "Vector is already free or was not set.\n"); parcMemory_Deallocate((void **) &vector); *vectorPtr = NULL; @@ -67,14 +67,14 @@ parcVector_Destroy(PARCVector **vectorPtr) const void * parcVector_GetPointer(const PARCVector *vector) { - assertNotNull(vector, "Parameter must be a non-null PARCVector pointer."); + parcAssertNotNull(vector, "Parameter must be a non-null PARCVector pointer."); return vector->pointer; } size_t parcVector_GetLength(const PARCVector *vector) { - assertNotNull(vector, "Parameter must be a non-null PARCVector pointer."); + parcAssertNotNull(vector, "Parameter must be a non-null PARCVector pointer."); return vector->length; } diff --git a/libparc/parc/algol/test/test_parc_ArrayList.c b/libparc/parc/algol/test/test_parc_ArrayList.c index 9e387a28..51e9e11c 100755 --- a/libparc/parc/algol/test/test_parc_ArrayList.c +++ b/libparc/parc/algol/test/test_parc_ArrayList.c @@ -641,11 +641,14 @@ LONGBOW_TEST_FIXTURE_TEARDOWN(Errors) LONGBOW_TEST_CASE_EXPECTS(Errors, PARC_ArrayList_InsertAtIndex_OutOfCapacity, .event = &LongBowAssertEvent) { PARCArrayList *array = longBowTestCase_GetClipBoardData(testCase); - + printf("1\n"); parcArrayList_Add(array, (void *) 1); + printf("2\n"); parcArrayList_Add(array, (void *) 2); + printf("3\n"); parcArrayList_InsertAtIndex(array, 200, (void *) 3); + printf("4\n"); } int -- cgit 1.2.3-korg