Browse Source

Merge commit '51d11a2' into HEAD

Conflicts:
	miner.c
	util.h
Luke Dashjr 13 years ago
parent
commit
55f1d71b5c
3 changed files with 12 additions and 3 deletions
  1. 4 1
      miner.c
  2. 1 2
      util.c
  3. 7 0
      util.h

+ 4 - 1
miner.c

@@ -6223,6 +6223,7 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
 	unsigned char *coinbase, merkle_root[32], merkle_sha[64], *merkle_hash;
 	int len, cb1_len, n1_len, cb2_len, i;
 	uint32_t *data32, *swap32;
+	size_t alloc_len;
 	char *header;
 
 	clean_work(work);
@@ -6236,7 +6237,9 @@ static void gen_stratum_work(struct pool *pool, struct work *work)
 	n1_len = strlen(pool->nonce1) / 2;
 	cb2_len = strlen(pool->swork.coinbase2) / 2;
 	len = cb1_len + n1_len + pool->n2size + cb2_len;
-	coinbase = alloca(len + 1);
+	alloc_len = len;
+	align_len(&alloc_len);
+	coinbase = alloca(alloc_len);
 	hex2bin(coinbase, pool->swork.coinbase1, cb1_len);
 	hex2bin(coinbase + cb1_len, pool->nonce1, n1_len);
 	hex2bin(coinbase + cb1_len + n1_len, work->nonce2, pool->n2size);

+ 1 - 2
util.c

@@ -1715,8 +1715,7 @@ void *realloc_strcat(char *ptr, char *s)
 		return ptr;
 
 	len += old + 1;
-	if (len % 4)
-		len += 4 - (len % 4);
+	align_len(&len);
 
 	ret = malloc(len);
 	if (unlikely(!ret))

+ 7 - 0
util.h

@@ -74,4 +74,11 @@ extern void notifier_init(int pipefd[2]);
 extern void notifier_wake(int fd[2]);
 extern void notifier_read(int fd[2]);
 
+/* Align a size_t to 4 byte boundaries for fussy arches */
+static inline void align_len(size_t *len)
+{
+	if (*len % 4)
+		*len += 4 - (*len % 4);
+}
+
 #endif /* __UTIL_H__ */