summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-08-25 15:21:08 +1000
committerAndrew Tridgell <tridge@samba.org>2010-08-25 23:05:05 +1000
commit717ee453dd72511bab2b7fc0e9712e67e5870421 (patch)
tree88169bbcda96dee88606e5ee7602c5c9e16226eb /source4
parentba5b3fb2480af2b3f8b5b69e4c161af07241e0c4 (diff)
downloadsamba-717ee453dd72511bab2b7fc0e9712e67e5870421.tar.gz
samba-717ee453dd72511bab2b7fc0e9712e67e5870421.tar.bz2
samba-717ee453dd72511bab2b7fc0e9712e67e5870421.zip
s4-pyglue: added talloc_total_blocks() python call
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/pyglue.c24
-rw-r--r--source4/scripting/python/samba/__init__.py1
2 files changed, 23 insertions, 2 deletions
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c
index ddd44aa7df..ec15e77a93 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -165,7 +165,7 @@ static PyObject *py_interface_ips(PyObject *self, PyObject *args)
return pylist;
}
-/* return a talloc tree string for a talloc python object */
+/* print a talloc tree report for a talloc python object */
static PyObject *py_talloc_report_full(PyObject *self, PyObject *args)
{
PyObject *py_obj;
@@ -183,13 +183,31 @@ static PyObject *py_talloc_report_full(PyObject *self, PyObject *args)
return Py_None;
}
-/* return a talloc tree string for a talloc python object */
+/* enable null tracking */
static PyObject *py_talloc_enable_null_tracking(PyObject *self, PyObject *args)
{
talloc_enable_null_tracking();
return Py_None;
}
+/* return the number of talloc blocks */
+static PyObject *py_talloc_total_blocks(PyObject *self, PyObject *args)
+{
+ PyObject *py_obj;
+ PyTypeObject *type;
+
+ if (!PyArg_ParseTuple(args, "O", &py_obj))
+ return NULL;
+
+ if (py_obj == Py_None) {
+ return PyLong_FromLong(talloc_total_blocks(NULL));
+ }
+
+ type = (PyTypeObject*)PyObject_Type(py_obj);
+
+ return PyLong_FromLong(talloc_total_blocks(py_talloc_get_mem_ctx(py_obj)));
+}
+
static PyMethodDef py_misc_methods[] = {
{ "generate_random_str", (PyCFunction)py_generate_random_str, METH_VARARGS,
@@ -212,6 +230,8 @@ static PyMethodDef py_misc_methods[] = {
"show a talloc tree for an object"},
{ "talloc_enable_null_tracking", (PyCFunction)py_talloc_enable_null_tracking, METH_VARARGS,
"enable tracking of the NULL object"},
+ { "talloc_total_blocks", (PyCFunction)py_talloc_total_blocks, METH_VARARGS,
+ "return talloc block count"},
{ NULL }
};
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index fcd224202b..72bbb4a7e3 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -329,3 +329,4 @@ unix2nttime = _glue.unix2nttime
generate_random_password = _glue.generate_random_password
talloc_report_full = _glue.talloc_report_full
talloc_enable_null_tracking = _glue.talloc_enable_null_tracking
+talloc_total_blocks = _glue.talloc_total_blocks