void *OICCalloc(size_t num, size_t size);
/**
- * Deallocate a block of memory previously allocated by a call to OCMalloc
+ * Deallocate a block of memory previously allocated by a call to OICMalloc.
+ * Furthermore the pointer is set value to NULL.
+ *
+ * @param ptr - Double Pointer to block of memory previously allocated by OICMalloc.
+ * If ptr is a null pointer, the function does nothing.
+ */
+void OICFreeAndSetToNull(void **ptr);
+
+/**
+ * Deallocate a block of memory previously allocated by a call to OICMalloc.
*
* NOTE: This function is intended to be used internally by the TB Stack.
* It is not intended to be used by applications.
EXPECT_TRUE(NULL == pBuffer);
OICFree(pBuffer);
}
+
+TEST(OICFreeAndSetToNull, FreeAndSetToNullPass1)
+{
+ // Try to deallocate a block of memory
+ pBuffer = (uint8_t *)OICCalloc(1, 1);
+ OICFreeAndSetToNull((void**)&pBuffer);
+ EXPECT_TRUE(NULL == pBuffer);
+}
+
+TEST(OICFreeAndSetToNull, FreeAndSetToNullPass2)
+{
+ // Try to deallocate a block of NULL
+ pBuffer = NULL;
+ OICFreeAndSetToNull((void**)&pBuffer);
+ EXPECT_TRUE(NULL == pBuffer);
+}