mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-31 19:24:42 +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)),
|
(word32)(sizeof(WOLFSSL_HEAP) + sizeof(WOLFSSL_HEAP_HINT)),
|
||||||
0, 1),
|
0, 1),
|
||||||
0);
|
0);
|
||||||
|
wc_UnloadStaticMemory(heap);
|
||||||
|
|
||||||
/* Success case. */
|
/* Success case. */
|
||||||
heap = NULL;
|
heap = NULL;
|
||||||
@@ -752,6 +753,7 @@ static int test_wc_LoadStaticMemory_ex(void)
|
|||||||
staticMemory, (word32)sizeof(staticMemory),
|
staticMemory, (word32)sizeof(staticMemory),
|
||||||
0, 1),
|
0, 1),
|
||||||
0);
|
0);
|
||||||
|
wc_UnloadStaticMemory(heap);
|
||||||
#endif /* WOLFSSL_STATIC_MEMORY */
|
#endif /* WOLFSSL_STATIC_MEMORY */
|
||||||
return EXPECT_RESULT();
|
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.
|
/* returns the size of management memory needed for each bucket.
|
||||||
* This is memory that is used to keep track of and align memory buckets. */
|
* This is memory that is used to keep track of and align memory buckets. */
|
||||||
int wolfSSL_MemoryPaddingSz(void)
|
int wolfSSL_MemoryPaddingSz(void)
|
||||||
|
@@ -222,6 +222,7 @@ WOLFSSL_API int wolfSSL_GetAllocators(wolfSSL_Malloc_cb* mf,
|
|||||||
int flag, int max);
|
int flag, int max);
|
||||||
WOLFSSL_API int wc_LoadStaticMemory(WOLFSSL_HEAP_HINT** pHint,
|
WOLFSSL_API int wc_LoadStaticMemory(WOLFSSL_HEAP_HINT** pHint,
|
||||||
unsigned char* buf, unsigned int sz, int flag, int max);
|
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_API int wolfSSL_GetMemStats(WOLFSSL_HEAP* heap,
|
||||||
WOLFSSL_MEM_STATS* stats);
|
WOLFSSL_MEM_STATS* stats);
|
||||||
|
Reference in New Issue
Block a user