X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/d7ab1bab81155baa763449d5afa81e16df98dbe7..6d4db0bf4b67e65708637466d4f0d306ed1dfe53:/algorithms.c diff --git a/algorithms.c b/algorithms.c index 6eda802..2113cc5 100644 --- a/algorithms.c +++ b/algorithms.c @@ -231,12 +231,12 @@ static PyMemberDef keyszset_pymembers[] = { }; static PyTypeObject keysz_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.KeySZ", /* @tp_name@ */ sizeof(keysz_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ - _PyObject_Del, /* @tp_dealloc@ */ + 0, /* @tp_dealloc@ */ 0, /* @tp_print@ */ 0, /* @tp_getattr@ */ 0, /* @tp_setattr@ */ @@ -274,17 +274,17 @@ static PyTypeObject keysz_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; static PyTypeObject keyszany_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.KeySZAny", /* @tp_name@ */ sizeof(keysz_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ - _PyObject_Del, /* @tp_dealloc@ */ + 0, /* @tp_dealloc@ */ 0, /* @tp_print@ */ 0, /* @tp_getattr@ */ 0, /* @tp_setattr@ */ @@ -322,17 +322,17 @@ static PyTypeObject keyszany_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ keyszany_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; static PyTypeObject keyszrange_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.KeySZRange", /* @tp_name@ */ sizeof(keyszrange_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ - _PyObject_Del, /* @tp_dealloc@ */ + 0, /* @tp_dealloc@ */ 0, /* @tp_print@ */ 0, /* @tp_getattr@ */ 0, /* @tp_setattr@ */ @@ -371,17 +371,17 @@ sizes, and requires the key length to be a multiple of some value.", 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ keyszrange_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; static PyTypeObject keyszset_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.KeySZSet", /* @tp_name@ */ sizeof(keyszset_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ - _PyObject_Del, /* @tp_dealloc@ */ + 0, /* @tp_dealloc@ */ 0, /* @tp_print@ */ 0, /* @tp_getattr@ */ 0, /* @tp_setattr@ */ @@ -420,7 +420,7 @@ few listed sizes.", 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ keyszset_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; @@ -460,19 +460,18 @@ end: PyObject *gccipher_pywrap(gccipher *cc) { - gccipher_pyobj *g = newtype(gccipher_pytype, 0); + gccipher_pyobj *g = newtype(gccipher_pytype, 0, cc->name); g->cc = cc; - g->ty.tp_name = (/*unconst*/ char *)cc->name; - g->ty.tp_basicsize = sizeof(gcipher_pyobj); - g->ty.tp_base = gcipher_pytype; + g->ty.type.tp_basicsize = sizeof(gcipher_pyobj); + g->ty.type.tp_base = gcipher_pytype; Py_INCREF(gcipher_pytype); - g->ty.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HEAPTYPE); - g->ty.tp_alloc = PyType_GenericAlloc; - g->ty.tp_free = _PyObject_Del; - g->ty.tp_new = gcipher_pynew; - PyType_Ready(&g->ty); + g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HEAPTYPE); + g->ty.type.tp_alloc = PyType_GenericAlloc; + g->ty.type.tp_free = 0; + g->ty.type.tp_new = gcipher_pynew; + PyType_Ready(&g->ty.type); return ((PyObject *)g); } @@ -481,7 +480,7 @@ static void gcipher_pydealloc(PyObject *me) if (GCIPHER_F(me) & f_freeme) GC_DESTROY(GCIPHER_C(me)); Py_DECREF(me->ob_type); - PyObject_DEL(me); + FREEOBJ(me); } static PyObject *gccget_name(PyObject *me, void *hunoz) @@ -591,7 +590,7 @@ static PyMethodDef gcipher_pymethods[] = { }; static PyTypeObject gccipher_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GCCipher", /* @tp_name@ */ sizeof(gccipher_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -634,12 +633,12 @@ static PyTypeObject gccipher_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; static PyTypeObject gcipher_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GCipher", /* @tp_name@ */ sizeof(gcipher_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -682,7 +681,7 @@ static PyTypeObject gcipher_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; @@ -705,19 +704,18 @@ end: PyObject *gchash_pywrap(gchash *ch) { - gchash_pyobj *g = newtype(gchash_pytype, 0); + gchash_pyobj *g = newtype(gchash_pytype, 0, ch->name); g->ch = ch; - g->ty.tp_name = (/*unconst*/ char *)ch->name; - g->ty.tp_basicsize = sizeof(ghash_pyobj); - g->ty.tp_base = ghash_pytype; + g->ty.type.tp_basicsize = sizeof(ghash_pyobj); + g->ty.type.tp_base = ghash_pytype; Py_INCREF(ghash_pytype); - g->ty.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HEAPTYPE); - g->ty.tp_alloc = PyType_GenericAlloc; - g->ty.tp_free = _PyObject_Del; - g->ty.tp_new = ghash_pynew; - PyType_Ready(&g->ty); + g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HEAPTYPE); + g->ty.type.tp_alloc = PyType_GenericAlloc; + g->ty.type.tp_free = 0; + g->ty.type.tp_new = ghash_pynew; + PyType_Ready(&g->ty.type); return ((PyObject *)g); } @@ -737,7 +735,7 @@ static void ghash_pydealloc(PyObject *me) if (GHASH_F(me) & f_freeme) GH_DESTROY(GHASH_H(me)); Py_DECREF(me->ob_type); - PyObject_DEL(me); + FREEOBJ(me); } static PyObject *gchget_name(PyObject *me, void *hunoz) @@ -788,7 +786,7 @@ static PyMethodDef ghash_pymethods[] = { }; static PyTypeObject gchash_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GCHash", /* @tp_name@ */ sizeof(gchash_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -831,12 +829,12 @@ static PyTypeObject gchash_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; static PyTypeObject ghash_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GHash", /* @tp_name@ */ sizeof(ghash_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -879,7 +877,7 @@ static PyTypeObject ghash_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; @@ -922,19 +920,18 @@ static PyObject *gmhash_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) PyObject *gcmac_pywrap(gcmac *cm) { - gcmac_pyobj *g = newtype(gcmac_pytype, 0); + gcmac_pyobj *g = newtype(gcmac_pytype, 0, cm->name); g->cm = cm; - g->ty.tp_name = (/*unconst*/ char *)cm->name; - g->ty.tp_basicsize = sizeof(gmac_pyobj); - g->ty.tp_base = gmac_pytype; + g->ty.type.tp_basicsize = sizeof(gmac_pyobj); + g->ty.type.tp_base = gmac_pytype; Py_INCREF(gmac_pytype); - g->ty.tp_flags = (Py_TPFLAGS_DEFAULT | + g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE); - g->ty.tp_alloc = PyType_GenericAlloc; - g->ty.tp_free = _PyObject_Del; - g->ty.tp_new = gmac_pynew; - PyType_Ready(&g->ty); + g->ty.type.tp_alloc = PyType_GenericAlloc; + g->ty.type.tp_free = 0; + g->ty.type.tp_new = gmac_pynew; + PyType_Ready(&g->ty.type); return ((PyObject *)g); } @@ -943,18 +940,18 @@ PyObject *gmac_pywrap(PyObject *cobj, gmac *m, unsigned f) gmac_pyobj *g; if (!cobj) cobj = gcmac_pywrap((/*unconst*/ gcmac *)GM_CLASS(m)); else Py_INCREF(cobj); - g = newtype((PyTypeObject *)cobj, 0); - g->nameobj = PyString_FromFormat("%s(keyed)", m->ops->c->name); - g->ty.tp_name = PyString_AS_STRING(g->nameobj); - g->ty.tp_base = gmhash_pytype; + g = newtype((PyTypeObject *)cobj, 0, 0); + g->ty.name = PyString_FromFormat("%s(keyed)", m->ops->c->name); + g->ty.type.tp_name = PyString_AS_STRING(g->ty.name); + g->ty.type.tp_base = gmhash_pytype; Py_INCREF(gmac_pytype); - g->ty.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_HEAPTYPE); - g->ty.tp_alloc = PyType_GenericAlloc; - g->ty.tp_free = _PyObject_Del; - g->ty.tp_new = gmhash_pynew; - PyType_Ready(&g->ty); + g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_HEAPTYPE); + g->ty.type.tp_alloc = PyType_GenericAlloc; + g->ty.type.tp_free = 0; + g->ty.type.tp_new = gmhash_pynew; + PyType_Ready(&g->ty.type); g->m = m; g->f = f; return ((PyObject *)g); @@ -965,7 +962,6 @@ static void gmac_pydealloc(PyObject *me) if (GMAC_F(me) & f_freeme) GM_DESTROY(GMAC_M(me)); Py_DECREF(me->ob_type); - Py_DECREF(GMAC_NAMEOBJ(me)); PyType_Type.tp_dealloc(me); } @@ -988,7 +984,7 @@ static PyGetSetDef gcmac_pygetset[] = { }; static PyTypeObject gcmac_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GCMAC", /* @tp_name@ */ sizeof(gchash_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -1031,12 +1027,12 @@ static PyTypeObject gcmac_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; static PyTypeObject gmac_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GMAC", /* @tp_name@ */ sizeof(gmac_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -1079,12 +1075,12 @@ static PyTypeObject gmac_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; static PyTypeObject gmhash_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ + PyObject_HEAD_INIT(0) 0, /* Header */ "catacomb.GMACHash", /* @tp_name@ */ sizeof(ghash_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -1127,7 +1123,7 @@ static PyTypeObject gmhash_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ };