From 93df8702113728341d8ad6d86ce847ea52b79c08 Mon Sep 17 00:00:00 2001 From: Magnus Ahltorp Date: Thu, 18 Feb 2016 13:56:07 +0100 Subject: Use pascal strings for keys --- c_src/permdbpy.c | 76 -------------------------------------------------------- 1 file changed, 76 deletions(-) (limited to 'c_src/permdbpy.c') diff --git a/c_src/permdbpy.c b/c_src/permdbpy.c index a98c83a..1e8c2f7 100644 --- a/c_src/permdbpy.c +++ b/c_src/permdbpy.c @@ -45,67 +45,6 @@ permdb_alloc_py(const char *dbpath) return state; } -typedef struct node_object_py { - PyObject_HEAD - node_object nodeobj; -} node_object_py; - -static void -pynode_dealloc(node_object_py *node) -{ - -} - -static PyObject* -node_getitem(PyObject *o, PyObject *key) -{ - unsigned int n = PyLong_AsUnsignedLong(key); - node_object_py *node = (node_object_py *)o; - - return PyLong_FromUnsignedLongLong(get_entry_in_node(node->nodeobj, n)); -} - -static PyMappingMethods node_as_mapping = { - 0, /* mp_length */ - node_getitem, /* mp_subscript */ - 0, /* mp_ass_subscript */ -}; - -static PyTypeObject node_type = { - PyObject_HEAD_INIT(NULL) - 0, /*ob_size*/ - "permdb.node", /*tp_name*/ - sizeof(node_object_py), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - (destructor)pynode_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - &node_as_mapping, /*tp_as_mapping*/ - 0, /*tp_hash */ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT, /*tp_flags*/ - "PermDB node", /*tp_doc*/ -}; - - -static node_object_py * -node_alloc(node_object data) -{ - node_object_py *node = PyObject_New(node_object_py, &node_type); - node->nodeobj = data; - return node; -} - - static PyObject * data_pread(PyObject *self, PyObject *args) { @@ -140,20 +79,6 @@ permdb_alloc_wrapper(PyObject *self, PyObject *args) } static PyObject * -readnode_wrapper(PyObject *self, PyObject *args) -{ - permdb_object_py *state; - unsigned long long offset; - const char *key = NULL; - - if (!PyArg_ParseTuple(args, "O!K|s", &permdb_type, &state, &offset, &key)) { - return NULL; - } - - return (PyObject *)node_alloc(readnode(state->permdb, offset, key)); -} - -static PyObject * datasize_wrapper(PyObject *self, PyObject *args) { permdb_object_py *state; @@ -255,7 +180,6 @@ committree_wrapper(PyObject *self, PyObject *args) static PyMethodDef UtilMethods[] = { {"data_pread", data_pread, METH_VARARGS}, {"alloc", permdb_alloc_wrapper, METH_VARARGS}, - {"readnode", readnode_wrapper, METH_VARARGS}, {"datasize", datasize_wrapper, METH_VARARGS}, {"addvalue", addvalue_wrapper, METH_VARARGS}, {"getvalue", getvalue_wrapper, METH_VARARGS}, -- cgit v1.1