pytalloc: Add some comments, use talloc object location in repr rather
authorJelmer Vernooij <jelmer@samba.org>
Tue, 23 Dec 2008 03:06:21 +0000 (04:06 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Tue, 23 Dec 2008 03:06:21 +0000 (04:06 +0100)
than python object location.

lib/talloc/pytalloc.c

index 8bc85eead647eebe8834f97a21e6b36a622dcef2..51d087b6d36188e9ad4561708e11a28462bfa671 100644 (file)
 */
 
 #include <talloc.h>
-#include "../lib/talloc/pytalloc.h"
+#include <pytalloc.h>
 
+/**
+ * Simple dealloc for talloc-wrapping PyObjects
+ */
 void py_talloc_dealloc(PyObject* self)
 {
        py_talloc_Object *obj = (py_talloc_Object *)self;
@@ -28,6 +31,9 @@ void py_talloc_dealloc(PyObject* self)
        self->ob_type->tp_free(self);
 }
 
+/**
+ * Import an existing talloc pointer into a Python object.
+ */
 PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx, 
                                                   void *ptr)
 {
@@ -43,10 +49,14 @@ PyObject *py_talloc_import_ex(PyTypeObject *py_type, TALLOC_CTX *mem_ctx,
        return (PyObject *)ret;
 }
 
-PyObject *py_talloc_default_repr(PyObject *py_obj)
+/**
+ * Default (but slightly more useful than the default) implementation of Repr().
+ */
+PyObject *py_talloc_default_repr(PyObject *obj)
 {
-       py_talloc_Object *obj = (py_talloc_Object *)py_obj;
-       PyTypeObject *type = (PyTypeObject*)PyObject_Type((PyObject *)obj);
+       py_talloc_Object *talloc_obj = (py_talloc_Object *)obj;
+       PyTypeObject *type = (PyTypeObject*)PyObject_Type(obj);
 
-       return PyString_FromFormat("<%s talloc object at 0x%x>", type->tp_name, (intptr_t)py_obj);
+       return PyString_FromFormat("<%s talloc object at 0x%x>", 
+                                  type->tp_name, (intptr_t)talloc_obj->ptr);
 }