diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2010-09-21 00:40:17 -0700 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2010-09-21 11:47:03 -0700 |
commit | 049c4fa04dcee5a6083630b0464b715c5ca531cd (patch) | |
tree | de66d564c8068bb52496883976198908f76f6d16 /lib/talloc/pytalloc.c | |
parent | 1d90227c3c31dae573ac1dc3096925cb82e994b6 (diff) | |
download | samba-049c4fa04dcee5a6083630b0464b715c5ca531cd.tar.gz samba-049c4fa04dcee5a6083630b0464b715c5ca531cd.tar.xz samba-049c4fa04dcee5a6083630b0464b715c5ca531cd.zip |
pytalloc: Add default compare function.
Diffstat (limited to 'lib/talloc/pytalloc.c')
-rw-r--r-- | lib/talloc/pytalloc.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c index 054704f42d..bea6961efc 100644 --- a/lib/talloc/pytalloc.c +++ b/lib/talloc/pytalloc.c @@ -88,7 +88,7 @@ PyObject *py_talloc_reference_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, voi } /** - * Default (but slightly more useful than the default) implementation of Repr(). + * Default (but only slightly more useful than the default) implementation of Repr(). */ PyObject *py_talloc_default_repr(PyObject *obj) { @@ -99,6 +99,19 @@ PyObject *py_talloc_default_repr(PyObject *obj) type->tp_name, talloc_obj->ptr); } +/** + * Default (but only slightly more useful than the default) implementation of cmp. + */ +int py_talloc_default_cmp(PyObject *_obj1, PyObject *_obj2) +{ + py_talloc_Object *obj1 = (py_talloc_Object *)_obj1, + *obj2 = (py_talloc_Object *)_obj2; + if (obj1->ob_type != obj2->ob_type) + return (obj1->ob_type - obj2->ob_type); + + return (py_talloc_get_ptr(obj1) - py_talloc_get_ptr(obj2)); +} + static void py_cobject_talloc_free(void *ptr) { talloc_free(ptr); |