mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
Generic Memory Pools
1. Add API for function `wc_UnloadStaticMemory()` which frees the mutex used by the static memory pool. 2. Update the `wc_LoadStaticMemory_ex()` test to free the static memory pool's mutex on each successful test case.
This commit is contained in:
@ -744,6 +744,7 @@ static int test_wc_LoadStaticMemory_ex(void)
|
||||
(word32)(sizeof(WOLFSSL_HEAP) + sizeof(WOLFSSL_HEAP_HINT)),
|
||||
0, 1),
|
||||
0);
|
||||
wc_UnloadStaticMemory(heap);
|
||||
|
||||
/* Success case. */
|
||||
heap = NULL;
|
||||
@ -752,6 +753,7 @@ static int test_wc_LoadStaticMemory_ex(void)
|
||||
staticMemory, (word32)sizeof(staticMemory),
|
||||
0, 1),
|
||||
0);
|
||||
wc_UnloadStaticMemory(heap);
|
||||
#endif /* WOLFSSL_STATIC_MEMORY */
|
||||
return EXPECT_RESULT();
|
||||
}
|
||||
|
@ -729,6 +729,15 @@ int wc_LoadStaticMemory(WOLFSSL_HEAP_HINT** pHint,
|
||||
}
|
||||
|
||||
|
||||
void wc_UnloadStaticMemory(WOLFSSL_HEAP_HINT* heap)
|
||||
{
|
||||
WOLFSSL_ENTER("wc_UnloadStaticMemory");
|
||||
if (heap != NULL && heap->memory != NULL) {
|
||||
wc_FreeMutex(&heap->memory->memory_mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* returns the size of management memory needed for each bucket.
|
||||
* This is memory that is used to keep track of and align memory buckets. */
|
||||
int wolfSSL_MemoryPaddingSz(void)
|
||||
|
@ -222,6 +222,7 @@ WOLFSSL_API int wolfSSL_GetAllocators(wolfSSL_Malloc_cb* mf,
|
||||
int flag, int max);
|
||||
WOLFSSL_API int wc_LoadStaticMemory(WOLFSSL_HEAP_HINT** pHint,
|
||||
unsigned char* buf, unsigned int sz, int flag, int max);
|
||||
WOLFSSL_API void wc_UnloadStaticMemory(WOLFSSL_HEAP_HINT* heap);
|
||||
|
||||
WOLFSSL_API int wolfSSL_GetMemStats(WOLFSSL_HEAP* heap,
|
||||
WOLFSSL_MEM_STATS* stats);
|
||||
|
Reference in New Issue
Block a user