From: Mark Wooding Date: Tue, 15 Oct 2019 10:48:12 +0000 (+0100) Subject: mp.c: Factor out and export `mphash'. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/commitdiff_plain/be6df1c38491ef517f2f55f2abc9c9e64ea034b0?ds=sidebyside mp.c: Factor out and export `mphash'. --- diff --git a/catacomb-python.h b/catacomb-python.h index 0307701..490862b 100644 --- a/catacomb-python.h +++ b/catacomb-python.h @@ -324,6 +324,7 @@ extern mp *getgf(PyObject *); extern int convgf(PyObject *, void *); extern PyObject *mp_pywrap(mp *); extern PyObject *gf_pywrap(mp *); +extern long mphash(mp *); extern mp *mp_frompyobject(PyObject *, int); extern PyObject *mp_topystring(mp *, int, const char *, const char *, const char *); diff --git a/mp.c b/mp.c index 88ee738..9330121 100644 --- a/mp.c +++ b/mp.c @@ -544,13 +544,15 @@ end: return ((PyObject *)zz); } -static long mp_pyhash(PyObject *me) +long mphash(mp *x) { - long h; - PyObject *l = mp_topylong(MP_X(me)); h = PyObject_Hash(l); + PyObject *l = mp_topylong(x); + long h = PyObject_Hash(l); Py_DECREF(l); return (h); } +static long mp_pyhash(PyObject *me) { return (mphash(MP_X(me))); } + static PyObject *mpmeth_jacobi(PyObject *me, PyObject *arg) { mp *y = 0;