Allow building with WOLFSSL_NO_MALLOC again

This commit is contained in:
Daniele Lacamera
2024-10-09 13:44:03 +02:00
parent ce9d0e236c
commit 43574e2255
3 changed files with 11 additions and 1 deletions

View File

@@ -968,6 +968,7 @@ int wc_ed25519ph_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
}
#endif /* HAVE_ED25519_VERIFY */
#ifndef WOLFSSL_NO_MALLOC
ed25519_key* wc_ed25519_new(void* heap, int devId)
{
ed25519_key* key = (ed25519_key*)XMALLOC(sizeof(ed25519_key), heap,
@@ -983,6 +984,7 @@ ed25519_key* wc_ed25519_new(void* heap, int devId)
}
return key;
}
#endif
/* initialize information and memory for key */
int wc_ed25519_init_ex(ed25519_key* key, void* heap, int devId)
@@ -1045,10 +1047,13 @@ void wc_ed25519_free(ed25519_key* key)
wc_MemZero_Check(key, sizeof(ed25519_key));
#endif
#ifndef WOLFSSL_NO_MALLOC
if (isAllocated) {
XFREE(key, heap, DYNAMIC_TYPE_ED25519);
(void)heap;
}
#endif
}

View File

@@ -686,6 +686,7 @@ int wc_Hash(enum wc_HashType hash_type, const byte* data,
NULL, INVALID_DEVID);
}
#ifndef WOLFSSL_NO_MALLOC
wc_HashAlg* wc_HashNew(enum wc_HashType type, void* heap, int devId)
{
wc_HashAlg* hash = (wc_HashAlg*)XMALLOC(sizeof(wc_HashAlg), heap,
@@ -701,6 +702,7 @@ wc_HashAlg* wc_HashNew(enum wc_HashType type, void* heap, int devId)
}
return hash;
}
#endif
int wc_HashInit_ex(wc_HashAlg* hash, enum wc_HashType type, void* heap,
int devId)
@@ -1170,10 +1172,12 @@ int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
ret = BAD_FUNC_ARG;
};
#ifndef WOLFSSL_NO_MALLOC
if (isAllocated) {
XFREE(hash, heap, DYNAMIC_TYPE_HASHES);
(void)heap;
}
#endif
return ret;
}

View File

@@ -943,7 +943,8 @@ typedef struct w64wrapper {
WOLFSSL_API int wc_strncasecmp(const char *s1, const char *s2, size_t n);
#endif
#if !defined(XSTRDUP) && !defined(USE_WOLF_STRDUP)
#if !defined(XSTRDUP) && !defined(USE_WOLF_STRDUP) &&\
!defined (WOLFSSL_NO_MALLOC)
#define USE_WOLF_STRDUP
#endif
#ifdef USE_WOLF_STRDUP