aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/tree-hash.c
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2019-03-17 17:56:52 +0200
committerRiccardo Spagni <ric@spagni.net>2019-03-17 17:56:52 +0200
commitc3de019f565674fd19b9d5cafba015d9ea7f69f7 (patch)
treedb6ee31b5f31cd2e1cf4b83dcd81895d24b51e5f /src/crypto/tree-hash.c
parentMerge pull request #5190 (diff)
parentperformance_tests: fix NetBSD build (diff)
downloadmonero-c3de019f565674fd19b9d5cafba015d9ea7f69f7.tar.xz
Merge pull request #5192
d0e07b3d performance_tests: fix NetBSD build (moneromooo-monero) 7d88d8f2 discontinue use of alloca (moneromooo-monero)
Diffstat (limited to 'src/crypto/tree-hash.c')
-rw-r--r--src/crypto/tree-hash.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/crypto/tree-hash.c b/src/crypto/tree-hash.c
index ce4b6cb75..7802fb67f 100644
--- a/src/crypto/tree-hash.c
+++ b/src/crypto/tree-hash.c
@@ -34,15 +34,6 @@
#include "hash-ops.h"
-#ifdef _MSC_VER
-#include <malloc.h>
-#elif !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__DragonFly__) \
- && !defined(__NetBSD__)
- #include <alloca.h>
-#else
- #include <stdlib.h>
-#endif
-
/***
* Round to power of two, for count>=3 and for count being not too large (as reasonable for tree hash calculations)
*/
@@ -91,9 +82,8 @@ void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash) {
size_t cnt = tree_hash_cnt( count );
- char (*ints)[HASH_SIZE];
- size_t ints_size = cnt * HASH_SIZE;
- ints = alloca(ints_size); memset( ints , 0 , ints_size); // allocate, and zero out as extra protection for using uninitialized mem
+ char ints[cnt][HASH_SIZE];
+ memset(ints, 0 , sizeof(ints)); // zero out as extra protection for using uninitialized mem
memcpy(ints, hashes, (2 * cnt - count) * HASH_SIZE);