Skip to content

Commit 4996aed

Browse files
Merge pull request #8117 from rizlik/static_mem_fix_types
memory: fix types in wc_LoadStaticMemory_ex()
2 parents c08bbf0 + dce9b2e commit 4996aed

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

wolfcrypt/src/memory.c

+4-9
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ static int wc_partition_static_memory(byte* buffer, word32 sz, int flag,
669669
}
670670

671671
static int wc_init_memory_heap(WOLFSSL_HEAP* heap, unsigned int listSz,
672-
const unsigned int* sizeList, const unsigned int* distList)
672+
const word32 *sizeList, const word32 *distList)
673673
{
674674
unsigned int i;
675675

@@ -695,8 +695,8 @@ static int wc_init_memory_heap(WOLFSSL_HEAP* heap, unsigned int listSz,
695695
}
696696

697697
int wc_LoadStaticMemory_ex(WOLFSSL_HEAP_HINT** pHint,
698-
unsigned int listSz, const unsigned int* sizeList,
699-
const unsigned int* distList, unsigned char* buf,
698+
unsigned int listSz, const word32 *sizeList,
699+
const word32 *distList, unsigned char *buf,
700700
unsigned int sz, int flag, int maxSz)
701701
{
702702
WOLFSSL_HEAP* heap = NULL;
@@ -773,13 +773,8 @@ int wc_LoadStaticMemory_ex(WOLFSSL_HEAP_HINT** pHint,
773773
int wc_LoadStaticMemory(WOLFSSL_HEAP_HINT** pHint,
774774
unsigned char* buf, unsigned int sz, int flag, int maxSz)
775775
{
776-
#ifdef WOLFSSL_LEAN_STATIC_PSK
777-
word16 sizeList[WOLFMEM_DEF_BUCKETS] = { WOLFMEM_BUCKETS };
778-
byte distList[WOLFMEM_DEF_BUCKETS] = { WOLFMEM_DIST };
779-
#else
780776
word32 sizeList[WOLFMEM_DEF_BUCKETS] = { WOLFMEM_BUCKETS };
781777
word32 distList[WOLFMEM_DEF_BUCKETS] = { WOLFMEM_DIST };
782-
#endif
783778
int ret = 0;
784779

785780
WOLFSSL_ENTER("wc_LoadStaticMemory");
@@ -817,7 +812,7 @@ int wolfSSL_MemoryPaddingSz(void)
817812
/* Used to calculate memory size for optimum use with buckets.
818813
returns the suggested size rounded down to the nearest bucket. */
819814
int wolfSSL_StaticBufferSz_ex(unsigned int listSz,
820-
const unsigned int *sizeList, const unsigned int *distList,
815+
const word32 *sizeList, const word32 *distList,
821816
byte* buffer, word32 sz, int flag)
822817
{
823818
word32 ava = sz;

wolfssl/wolfcrypt/memory.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ WOLFSSL_API int wolfSSL_GetAllocators(wolfSSL_Malloc_cb* mf,
219219
#endif
220220

221221
#ifdef WOLFSSL_STATIC_MEMORY_LEAN
222-
word16 sizeList[WOLFMEM_MAX_BUCKETS];/* memory sizes in ava list */
223-
byte distList[WOLFMEM_MAX_BUCKETS];/* general distribution */
222+
word32 sizeList[WOLFMEM_MAX_BUCKETS];/* memory sizes in ava list */
223+
word32 distList[WOLFMEM_MAX_BUCKETS];/* general distribution */
224224
#else
225225
word32 maxHa; /* max concurrent handshakes */
226226
word32 curHa;
@@ -258,8 +258,8 @@ WOLFSSL_API int wolfSSL_GetAllocators(wolfSSL_Malloc_cb* mf,
258258
WOLFSSL_API void* wolfSSL_SetGlobalHeapHint(void* heap);
259259
WOLFSSL_API void* wolfSSL_GetGlobalHeapHint(void);
260260
WOLFSSL_API int wc_LoadStaticMemory_ex(WOLFSSL_HEAP_HINT** pHint,
261-
unsigned int listSz, const unsigned int *sizeList,
262-
const unsigned int *distList, unsigned char* buf, unsigned int sz,
261+
unsigned int listSz, const word32 *sizeList,
262+
const word32 *distList, unsigned char* buf, unsigned int sz,
263263
int flag, int max);
264264
#ifdef WOLFSSL_STATIC_MEMORY_DEBUG_CALLBACK
265265
#define WOLFSSL_DEBUG_MEMORY_ALLOC 0
@@ -281,7 +281,7 @@ WOLFSSL_API int wolfSSL_GetAllocators(wolfSSL_Malloc_cb* mf,
281281
WOLFSSL_LOCAL int FreeFixedIO(WOLFSSL_HEAP* heap, wc_Memory** io);
282282

283283
WOLFSSL_API int wolfSSL_StaticBufferSz_ex(unsigned int listSz,
284-
const unsigned int *sizeList, const unsigned int *distList,
284+
const word32 *sizeList, const word32 *distList,
285285
byte* buffer, word32 sz, int flag);
286286
WOLFSSL_API int wolfSSL_StaticBufferSz(byte* buffer, word32 sz, int flag);
287287
WOLFSSL_API int wolfSSL_MemoryPaddingSz(void);

0 commit comments

Comments
 (0)