changeset 16757:923bd97b86a0

mpatch: use Py_ssize_t Eliminates mpatch.c(73) : warning C4244: 'return' : conversion from '__int64' to 'int', possible loss of data mpatch.c(299) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data mpatch.c(321) : warning C4244: '=' : conversion from 'Py_ssize_t' to 'int', possible loss of data mpatch.c(335) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data mpatch.c(346) : warning C4244: 'function' : conversion from 'Py_ssize_t' to 'int', possible loss of data when compiling for Windows x64 target using the Microsoft compiler.
author Adrian Buehlmann <adrian@cadifra.com>
date Sun, 20 May 2012 00:08:18 +0200
parents 2e3513e7348a
children 9a8ab5c47f84
files mercurial/mpatch.c
diffstat 1 files changed, 9 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/mpatch.c	Sun May 20 21:11:34 2012 +0300
+++ b/mercurial/mpatch.c	Sun May 20 00:08:18 2012 +0200
@@ -38,7 +38,7 @@
 	struct frag *base, *head, *tail;
 };
 
-static struct flist *lalloc(int size)
+static struct flist *lalloc(Py_ssize_t size)
 {
 	struct flist *a = NULL;
 
@@ -68,7 +68,7 @@
 	}
 }
 
-static int lsize(struct flist *a)
+static Py_ssize_t lsize(struct flist *a)
 {
 	return a->tail - a->head;
 }
@@ -197,7 +197,7 @@
 }
 
 /* decode a binary patch into a hunk list */
-static struct flist *decode(const char *bin, int len)
+static struct flist *decode(const char *bin, Py_ssize_t len)
 {
 	struct flist *l;
 	struct frag *lt;
@@ -236,9 +236,9 @@
 }
 
 /* calculate the size of resultant text */
-static int calcsize(int len, struct flist *l)
+static Py_ssize_t calcsize(Py_ssize_t len, struct flist *l)
 {
-	int outlen = 0, last = 0;
+	Py_ssize_t outlen = 0, last = 0;
 	struct frag *f = l->head;
 
 	while (f != l->tail) {
@@ -258,7 +258,7 @@
 	return outlen;
 }
 
-static int apply(char *buf, const char *orig, int len, struct flist *l)
+static int apply(char *buf, const char *orig, Py_ssize_t len, struct flist *l)
 {
 	struct frag *f = l->head;
 	int last = 0;
@@ -283,10 +283,9 @@
 }
 
 /* recursively generate a patch of all bins between start and end */
-static struct flist *fold(PyObject *bins, int start, int end)
+static struct flist *fold(PyObject *bins, Py_ssize_t start, Py_ssize_t end)
 {
-	int len;
-	Py_ssize_t blen;
+	Py_ssize_t len, blen;
 	const char *buffer;
 
 	if (start + 1 == end) {
@@ -312,8 +311,7 @@
 	struct flist *patch;
 	const char *in;
 	char *out;
-	int len, outlen;
-	Py_ssize_t inlen;
+	Py_ssize_t len, outlen, inlen;
 
 	if (!PyArg_ParseTuple(args, "OO:mpatch", &text, &bins))
 		return NULL;