summaryrefslogtreecommitdiff
path: root/source4/lib/ldb
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-03-21 01:00:18 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-03-21 01:00:18 +0100
commitde1e3e2cf0c666a51b062ed5395906892beb53c0 (patch)
treec5bcc8df77bee9c92f55120a0bab56293b61d8e2 /source4/lib/ldb
parent8f4e4d2e3039997106f9da3dcd5b057d99802ecf (diff)
downloadsamba-de1e3e2cf0c666a51b062ed5395906892beb53c0.tar.gz
samba-de1e3e2cf0c666a51b062ed5395906892beb53c0.tar.bz2
samba-de1e3e2cf0c666a51b062ed5395906892beb53c0.zip
Remove unnecessary duplication of string in memory.
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r--source4/lib/ldb/pyldb.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/source4/lib/ldb/pyldb.c b/source4/lib/ldb/pyldb.c
index b91f9b797f..3e3aa97240 100644
--- a/source4/lib/ldb/pyldb.c
+++ b/source4/lib/ldb/pyldb.c
@@ -1276,6 +1276,21 @@ PyTypeObject PyLdbModule = {
.tp_flags = Py_TPFLAGS_DEFAULT,
};
+
+/**
+ * Create a ldb_message_element from a Python object.
+ *
+ * This will accept any sequence objects that contains strings, or
+ * a string object.
+ *
+ * A reference to set_obj will be borrowed.
+ *
+ * @param mem_ctx Memory context
+ * @param set_obj Python object to convert
+ * @param flags ldb_message_element flags to set
+ * @param attr_name Name of the attribute
+ * @return New ldb_message_element, allocated as child of mem_ctx
+ */
struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx,
PyObject *set_obj, int flags,
const char *attr_name)
@@ -1293,11 +1308,7 @@ struct ldb_message_element *PyObject_AsMessageElement(TALLOC_CTX *mem_ctx,
me->num_values = 1;
me->values = talloc_array(me, struct ldb_val, me->num_values);
me->values[0].length = PyString_Size(set_obj);
- me->values[0].data = (uint8_t *)talloc_memdup(me->values,
- PyString_AsString(set_obj),
- me->values[0].length + 1);
- me->values[0].data[me->values[0].length] = '\0';
-
+ me->values[0].data = (uint8_t *)PyString_AsString(set_obj);
} else if (PySequence_Check(set_obj)) {
int i;
me->num_values = PySequence_Size(set_obj);