Enable mbedTLS dynamic memory allocation in user mode on Windows (#1373)

* change user mode openthread to enable dynamic memory allocation in mbedtls

* complete merge by adding OPENTHREAD_MULTIPLE_INSTANCE to last file

* remove some extraneous changes that got pulled in accidentally

* fix spacing

* fix crash in existing tests due to this change

* fix x86 build
This commit is contained in:
Jorge Vergara
2017-02-23 22:01:59 -08:00
committed by Jonathan Hui
parent 1587835134
commit f3817e76cf
17 changed files with 77 additions and 10 deletions
+21
View File
@@ -192,7 +192,23 @@ void TestMessageQueueOtApis(void)
ThreadError error;
otMessage message;
#ifdef OPENTHREAD_MULTIPLE_INSTANCE
size_t otInstanceBufferLength = 0;
uint8_t *otInstanceBuffer = NULL;
// Call to query the buffer size
(void)otInstanceInit(NULL, &otInstanceBufferLength);
// Call to allocate the buffer
otInstanceBuffer = (uint8_t *)malloc(otInstanceBufferLength);
assert(otInstanceBuffer);
// Initialize Openthread with the buffer
instance = otInstanceInit(otInstanceBuffer, &otInstanceBufferLength);
#else
instance = otInstanceInit();
#endif
VerifyOrQuit(instance != NULL, "Failed to get and init an otInstance.\n");
for (int i = 0; i < kNumTestMessages; i++)
@@ -251,6 +267,11 @@ void TestMessageQueueOtApis(void)
// Remove all element and make sure queue is empty
SuccessOrQuit(otMessageQueueDequeue(&queue, msg[2]), "Failed to dequeue a message from otMessageQueue.\n");
VerifyMessageQueueContentUsingOtApi(&queue, 0);
otInstanceFinalize(instance);
#ifdef OPENTHREAD_MULTIPLE_INSTANCE
free(otInstanceBuffer);
#endif
}
#ifdef ENABLE_TEST_MAIN