vendor/cmock/src/cmock.c in ceedling-0.15.1 vs vendor/cmock/src/cmock.c in ceedling-0.15.2

- old
+ new

@@ -36,11 +36,11 @@ size = (size + CMOCK_MEM_ALIGN_MASK) & ~CMOCK_MEM_ALIGN_MASK; if ((CMock_Guts_BufferSize - CMock_Guts_FreePtr) < size) { #ifdef CMOCK_MEM_DYNAMIC CMock_Guts_BufferSize += CMOCK_MEM_SIZE + size; - CMock_Guts_Buffer = realloc(CMock_Guts_Buffer, CMock_Guts_BufferSize); + CMock_Guts_Buffer = realloc(CMock_Guts_Buffer, (size_t)CMock_Guts_BufferSize); if (CMock_Guts_Buffer == NULL) #endif //yes that if will continue to the return below if TRUE return CMOCK_GUTS_NONE; } @@ -76,11 +76,11 @@ } if ((obj_index < CMOCK_MEM_ALIGN_SIZE) || (obj_index >= CMock_Guts_FreePtr)) { return CMOCK_GUTS_NONE; } - + root = (void*)(&CMock_Guts_Buffer[root_index]); obj = (void*)(&CMock_Guts_Buffer[obj_index]); //find the end of the existing chain and add us next = root; @@ -89,11 +89,11 @@ if (index >= CMock_Guts_FreePtr) return CMOCK_GUTS_NONE; if (index > 0) next = (void*)(&CMock_Guts_Buffer[index]); } while (index > 0); - *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)next - CMOCK_MEM_INDEX_SIZE) = ((CMOCK_MEM_PTR_AS_INT)obj - (CMOCK_MEM_PTR_AS_INT)CMock_Guts_Buffer); + *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)next - CMOCK_MEM_INDEX_SIZE) = (CMOCK_MEM_INDEX_TYPE)((CMOCK_MEM_PTR_AS_INT)obj - (CMOCK_MEM_PTR_AS_INT)CMock_Guts_Buffer); return root_index; } } //------------------------------------------------------- @@ -123,11 +123,11 @@ //------------------------------------------------------- CMOCK_MEM_INDEX_TYPE CMock_Guts_MemEndOfChain(CMOCK_MEM_INDEX_TYPE root_index) { CMOCK_MEM_INDEX_TYPE index = root_index; CMOCK_MEM_INDEX_TYPE next_index; - + for (next_index = root_index; next_index != CMOCK_GUTS_NONE; next_index = CMock_Guts_MemNext(index)) { index = next_index; @@ -172,5 +172,21 @@ //------------------------------------------------------- void CMock_Guts_MemFreeAll(void) { CMock_Guts_FreePtr = CMOCK_MEM_ALIGN_SIZE; //skip the very beginning } + +//------------------------------------------------------- +// CMock_Guts_MemFreeFinal +//------------------------------------------------------- +void CMock_Guts_MemFreeFinal(void) +{ + CMock_Guts_FreePtr = CMOCK_MEM_ALIGN_SIZE; +#ifdef CMOCK_MEM_DYNAMIC + if (CMock_Guts_Buffer) + { + free(CMock_Guts_Buffer); + CMock_Guts_Buffer = NULL; + } +#endif +} +