diff mercurial/thirdparty/xdiff/xutils.c @ 36825:f1ef0e53e628

xdiff: use int64 for hash table size Follow-up of the previous "long" -> "int64" change. Now xdiff only uses int for return values and small integers (ex. booleans, shifting score, bits in hash table size, etc) so it should be able to handle large input. Differential Revision: https://phab.mercurial-scm.org/D2765
author Jun Wu <quark@fb.com>
date Fri, 09 Mar 2018 14:47:29 -0800
parents 49fe6249937a
children
line wrap: on
line diff
--- a/mercurial/thirdparty/xdiff/xutils.c	Fri Mar 09 14:39:35 2018 -0800
+++ b/mercurial/thirdparty/xdiff/xutils.c	Fri Mar 09 14:47:29 2018 -0800
@@ -141,9 +141,10 @@
 	return ha;
 }
 
-unsigned int xdl_hashbits(unsigned int size) {
-	unsigned int val = 1, bits = 0;
+unsigned int xdl_hashbits(int64_t size) {
+	int64_t val = 1;
+	unsigned int bits = 0;
 
-	for (; val < size && bits < CHAR_BIT * sizeof(unsigned int); val <<= 1, bits++);
+	for (; val < size && bits < (int64_t) CHAR_BIT * sizeof(unsigned int); val <<= 1, bits++);
 	return bits ? bits: 1;
 }