[PATCH 1 of 5] mpatch: change Py_ssize_t to ssize_t in places that will be later copied

Maciej Fijalkowski fijall at gmail.com
Mon Jul 25 09:10:55 EDT 2016


# HG changeset patch
# User Maciej Fijalkowski <fijall at gmail.com>
# Date 1468847680 -7200
#      Mon Jul 18 15:14:40 2016 +0200
# Node ID c6e9531e8de55ec7310866e1aa452c4c914b8daa
# Parent  583ab8acdad3890153b34989241fd91d96a7a275
mpatch: change Py_ssize_t to ssize_t in places that will be later copied

diff --git a/mercurial/mpatch.c b/mercurial/mpatch.c
--- a/mercurial/mpatch.c
+++ b/mercurial/mpatch.c
@@ -27,6 +27,7 @@
 
 #include "util.h"
 #include "bitmanipulation.h"
+#include "compat.h"
 
 static char mpatch_doc[] = "Efficient binary patching.";
 static PyObject *mpatch_Error;
@@ -40,7 +41,7 @@
 	struct frag *base, *head, *tail;
 };
 
-static struct flist *lalloc(Py_ssize_t size)
+static struct flist *lalloc(ssize_t size)
 {
 	struct flist *a = NULL;
 
@@ -70,7 +71,7 @@
 	}
 }
 
-static Py_ssize_t lsize(struct flist *a)
+static ssize_t lsize(struct flist *a)
 {
 	return a->tail - a->head;
 }
@@ -199,7 +200,7 @@
 }
 
 /* decode a binary patch into a hunk list */
-static struct flist *decode(const char *bin, Py_ssize_t len)
+static struct flist *decode(const char *bin, ssize_t len)
 {
 	struct flist *l;
 	struct frag *lt;
@@ -235,9 +236,9 @@
 }
 
 /* calculate the size of resultant text */
-static Py_ssize_t calcsize(Py_ssize_t len, struct flist *l)
+static ssize_t calcsize(ssize_t len, struct flist *l)
 {
-	Py_ssize_t outlen = 0, last = 0;
+	ssize_t outlen = 0, last = 0;
 	struct frag *f = l->head;
 
 	while (f != l->tail) {
@@ -257,7 +258,7 @@
 	return outlen;
 }
 
-static int apply(char *buf, const char *orig, Py_ssize_t len, struct flist *l)
+static int apply(char *buf, const char *orig, ssize_t len, struct flist *l)
 {
 	struct frag *f = l->head;
 	int last = 0;
@@ -282,9 +283,9 @@
 }
 
 /* recursively generate a patch of all bins between start and end */
-static struct flist *fold(PyObject *bins, Py_ssize_t start, Py_ssize_t end)
+static struct flist *fold(PyObject *bins, ssize_t start, ssize_t end)
 {
-	Py_ssize_t len, blen;
+	ssize_t len, blen;
 	const char *buffer;
 
 	if (start + 1 == end) {


More information about the Mercurial-devel mailing list