diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-01-11 16:45:39 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-01-14 16:39:32 +1100 |
commit | 5322567530d588d0f420eeb720c9a2e3225d6007 (patch) | |
tree | 090038f9377e6dc6a3cef63a93433c41195fa000 /source4/lib/ldb | |
parent | edd3b033b861cf9e747c35a2345e714b4b2122a9 (diff) | |
download | samba-5322567530d588d0f420eeb720c9a2e3225d6007.tar.gz samba-5322567530d588d0f420eeb720c9a2e3225d6007.tar.bz2 samba-5322567530d588d0f420eeb720c9a2e3225d6007.zip |
pyldb Simplify python wrappers for struct ldb_val (LdbValue)
Andrew Bartlett
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/pyldb.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c index c2d75b43d3..17c0734cf6 100644 --- a/source4/lib/ldb/pyldb.c +++ b/source4/lib/ldb/pyldb.c @@ -72,21 +72,9 @@ static void PyErr_SetLdbError(PyObject *error, int ret, struct ldb_context *ldb_ ldb_ctx == NULL?ldb_strerror(ret):ldb_errstring(ldb_ctx))); } -static PyObject *PyObject_FromLdbValue(struct ldb_context *ldb_ctx, - struct ldb_message_element *el, - struct ldb_val *val) +static PyObject *PyObject_FromLdbValue(struct ldb_val *val) { - struct ldb_val new_val; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - PyObject *ret; - - new_val = *val; - - ret = PyString_FromStringAndSize((const char *)new_val.data, new_val.length); - - talloc_free(mem_ctx); - - return ret; + return PyString_FromStringAndSize((const char *)val->data, val->length); } /** @@ -1805,7 +1793,7 @@ static PyObject *ldb_msg_element_to_set(struct ldb_context *ldb_ctx, for (i = 0; i < me->num_values; i++) { PyList_SetItem(result, i, - PyObject_FromLdbValue(ldb_ctx, me, &me->values[i])); + PyObject_FromLdbValue(&me->values[i])); } return result; @@ -1819,8 +1807,7 @@ static PyObject *py_ldb_msg_element_get(PyLdbMessageElementObject *self, PyObjec if (i >= PyLdbMessageElement_AsMessageElement(self)->num_values) Py_RETURN_NONE; - return PyObject_FromLdbValue(NULL, PyLdbMessageElement_AsMessageElement(self), - &(PyLdbMessageElement_AsMessageElement(self)->values[i])); + return PyObject_FromLdbValue(&(PyLdbMessageElement_AsMessageElement(self)->values[i])); } static PyObject *py_ldb_msg_element_flags(PyLdbMessageElementObject *self, PyObject *args) |