Skip to content

Commit 43574e2

Browse files
committed
Allow building with WOLFSSL_NO_MALLOC again
1 parent ce9d0e2 commit 43574e2

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

wolfcrypt/src/ed25519.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@ int wc_ed25519ph_verify_msg(const byte* sig, word32 sigLen, const byte* msg,
968968
}
969969
#endif /* HAVE_ED25519_VERIFY */
970970

971+
#ifndef WOLFSSL_NO_MALLOC
971972
ed25519_key* wc_ed25519_new(void* heap, int devId)
972973
{
973974
ed25519_key* key = (ed25519_key*)XMALLOC(sizeof(ed25519_key), heap,
@@ -983,6 +984,7 @@ ed25519_key* wc_ed25519_new(void* heap, int devId)
983984
}
984985
return key;
985986
}
987+
#endif
986988

987989
/* initialize information and memory for key */
988990
int wc_ed25519_init_ex(ed25519_key* key, void* heap, int devId)
@@ -1045,10 +1047,13 @@ void wc_ed25519_free(ed25519_key* key)
10451047
wc_MemZero_Check(key, sizeof(ed25519_key));
10461048
#endif
10471049

1050+
#ifndef WOLFSSL_NO_MALLOC
10481051
if (isAllocated) {
10491052
XFREE(key, heap, DYNAMIC_TYPE_ED25519);
10501053
(void)heap;
10511054
}
1055+
#endif
1056+
10521057
}
10531058

10541059

wolfcrypt/src/hash.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ int wc_Hash(enum wc_HashType hash_type, const byte* data,
686686
NULL, INVALID_DEVID);
687687
}
688688

689+
#ifndef WOLFSSL_NO_MALLOC
689690
wc_HashAlg* wc_HashNew(enum wc_HashType type, void* heap, int devId)
690691
{
691692
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)
701702
}
702703
return hash;
703704
}
705+
#endif
704706

705707
int wc_HashInit_ex(wc_HashAlg* hash, enum wc_HashType type, void* heap,
706708
int devId)
@@ -1170,10 +1172,12 @@ int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
11701172
ret = BAD_FUNC_ARG;
11711173
};
11721174

1175+
#ifndef WOLFSSL_NO_MALLOC
11731176
if (isAllocated) {
11741177
XFREE(hash, heap, DYNAMIC_TYPE_HASHES);
11751178
(void)heap;
11761179
}
1180+
#endif
11771181

11781182
return ret;
11791183
}

wolfssl/wolfcrypt/types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,8 @@ typedef struct w64wrapper {
943943
WOLFSSL_API int wc_strncasecmp(const char *s1, const char *s2, size_t n);
944944
#endif
945945

946-
#if !defined(XSTRDUP) && !defined(USE_WOLF_STRDUP)
946+
#if !defined(XSTRDUP) && !defined(USE_WOLF_STRDUP) &&\
947+
!defined (WOLFSSL_NO_MALLOC)
947948
#define USE_WOLF_STRDUP
948949
#endif
949950
#ifdef USE_WOLF_STRDUP

0 commit comments

Comments
 (0)