@@ -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
689690wc_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
705707int wc_HashInit_ex (wc_HashAlg * hash , enum wc_HashType type , void * heap ,
706708 int devId )
@@ -710,7 +712,9 @@ int wc_HashInit_ex(wc_HashAlg* hash, enum wc_HashType type, void* heap,
710712 if (hash == NULL )
711713 return BAD_FUNC_ARG ;
712714
715+ #ifndef WOLFSSL_NO_MALLOC
713716 hash -> isAllocated = 0 ;
717+ #endif
714718 hash -> type = type ;
715719
716720 switch (type ) {
@@ -1042,19 +1046,23 @@ int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
10421046{
10431047 int ret = WC_NO_ERR_TRACE (HASH_TYPE_E ); /* Default to hash type error */
10441048 void * heap = NULL ;
1049+ #ifndef WOLFSSL_NO_MALLOC
10451050 byte isAllocated = 0 ;
1046-
1051+ #endif
10471052 if (hash == NULL )
10481053 return BAD_FUNC_ARG ;
10491054
1055+
10501056#ifdef DEBUG_WOLFSSL
10511057 if (hash -> type != type ) {
10521058 WOLFSSL_MSG ("Hash free type mismatch!" );
10531059 return BAD_FUNC_ARG ;
10541060 }
10551061#endif
10561062
1063+ #ifndef WOLFSSL_NO_MALLOC
10571064 isAllocated = hash -> isAllocated ;
1065+ #endif
10581066
10591067 switch (type ) {
10601068 case WC_HASH_TYPE_MD5 :
@@ -1170,10 +1178,12 @@ int wc_HashFree(wc_HashAlg* hash, enum wc_HashType type)
11701178 ret = BAD_FUNC_ARG ;
11711179 };
11721180
1181+ #ifndef WOLFSSL_NO_MALLOC
11731182 if (isAllocated ) {
11741183 XFREE (hash , heap , DYNAMIC_TYPE_HASHES );
1175- (void )heap ;
11761184 }
1185+ #endif
1186+ (void )heap ;
11771187
11781188 return ret ;
11791189}
0 commit comments