catacomb.c, ec.c, group.c, mp.c: Count base/exponent pairs with `size_t'.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 18 Oct 2019 20:24:23 +0000 (21:24 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 11 Apr 2020 11:55:26 +0000 (12:55 +0100)
Admittedly, if you get even slightly close to the limits of an `int',
the calculation will take an infinite amount of time.

catacomb-python.h
catacomb.c
ec.c
group.c
mp.c

index aa55cc5..6128cc8 100644 (file)
@@ -151,7 +151,7 @@ extern PyObject *mexp_common(PyObject *, PyObject *, size_t,
                             PyObject *(*id)(PyObject *),
                             int (*fill)(void *, PyObject *,
                                         PyObject *, PyObject *),
-                            PyObject *(*exp)(PyObject *, void *, int),
+                            PyObject *(*exp)(PyObject *, void *, size_t),
                             void (*drop)(void *));
 
 /*----- Bytestrings -------------------------------------------------------*/
index d994347..1f38213 100644 (file)
@@ -35,10 +35,11 @@ PyObject *mexp_common(PyObject *me, PyObject *arg,
                      PyObject *(*id)(PyObject *),
                      int (*fill)(void *, PyObject *,
                                  PyObject *, PyObject *),
-                     PyObject *(*exp)(PyObject *, void *, int),
+                     PyObject *(*exp)(PyObject *, void *, size_t),
                      void (*drop)(void *))
 {
-  int i = 0, j, n, flat;
+  size_t i = 0, j, n;
+  int flat;
   PyObject *qq, *x, *y, *z = 0;
   char *v = 0, *vv;
 
diff --git a/ec.c b/ec.c
index 9af2b0c..2ab20a6 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -913,7 +913,7 @@ static int ecmmul_fill(void *pp, PyObject *me, PyObject *x, PyObject *m)
   return (0);
 }
 
-static PyObject *ecmmul_exp(PyObject *me, void *pp, int n)
+static PyObject *ecmmul_exp(PyObject *me, void *pp, size_t n)
 {
   ec p = EC_INIT;
   ec_immul(ECCURVE_C(me), &p, pp, n);
diff --git a/group.c b/group.c
index 1e93ccc..77c3e9f 100644 (file)
--- a/group.c
+++ b/group.c
@@ -773,7 +773,7 @@ static PyObject *gemeth_toraw(PyObject *me)
   return (rc);
 }
 
-static PyObject *gmexp_exp(PyObject *me, void *pp, int n)
+static PyObject *gmexp_exp(PyObject *me, void *pp, size_t n)
 {
   ge *z = G_CREATE(GROUP_G(me));
   G_MEXP(GROUP_G(me), z, pp, n);
diff --git a/mp.c b/mp.c
index 456c905..265a5c8 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -1332,7 +1332,7 @@ fail:
   return (-1);
 }
 
-static PyObject *mm_mexpr(PyObject *me, void *v, int n)
+static PyObject *mm_mexpr(PyObject *me, void *v, size_t n)
   { return mp_pywrap(mpmont_mexpr(MPMONT_PY(me), MP_NEW, v, n)); }
 
 static void mp_mexp_drop(void *p)
@@ -1372,7 +1372,7 @@ fail:
   return (-1);
 }
 
-static PyObject *mm_mexp(PyObject *me, void *v, int n)
+static PyObject *mm_mexp(PyObject *me, void *v, size_t n)
   { return mp_pywrap(mpmont_mexp(MPMONT_PY(me), MP_NEW, v, n)); }
 
 static PyObject *mmmeth_mexp(PyObject *me, PyObject *arg)
@@ -1527,7 +1527,7 @@ end:
   return (rc);
 }
 
-static PyObject *mb_mexp(PyObject *me, void *v, int n)
+static PyObject *mb_mexp(PyObject *me, void *v, size_t n)
   { return mp_pywrap(mpbarrett_mexp(MPBARRETT_PY(me), MP_NEW, v, n)); }
 
 static PyObject *mbmeth_mexp(PyObject *me, PyObject *arg)