pycredentials: Remove PyCredentialCacheContainerObject
authorAndrew Bartlett <abartlet@samba.org>
Mon, 29 Feb 2016 03:26:08 +0000 (16:26 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 8 Mar 2016 00:58:29 +0000 (01:58 +0100)
We can call pytalloc_reference() and avoid having this in the header file

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
auth/credentials/pycredentials.c
auth/credentials/pycredentials.h

index e1c0b3ece759b7f84a2a3f4d60bf1a09829a3d6f..77671d0b4169868968b3148044e8eff9bbb3db9c 100644 (file)
@@ -315,20 +315,7 @@ static PyObject *py_creds_set_machine_account(PyObject *self, PyObject *args)
 
 static PyObject *PyCredentialCacheContainer_from_ccache_container(struct ccache_container *ccc)
 {
-       PyCredentialCacheContainerObject *py_ret;
-
-       if (ccc == NULL) {
-               Py_RETURN_NONE;
-       }
-
-       py_ret = (PyCredentialCacheContainerObject *)PyCredentialCacheContainer.tp_alloc(&PyCredentialCacheContainer, 0);
-       if (py_ret == NULL) {
-               PyErr_NoMemory();
-               return NULL;
-       }
-       py_ret->mem_ctx = talloc_new(NULL);
-       py_ret->ccc = talloc_reference(py_ret->mem_ctx, ccc);
-       return (PyObject *)py_ret;
+       return pytalloc_reference(&PyCredentialCacheContainer, ccc);
 }
 
 
index 3a110fb09a54132799944f843db1cb1aef8c73b6..a136a210da359b0c92daaec73d5f77a286a63ff5 100644 (file)
 
 extern PyTypeObject PyCredentials;
 extern PyTypeObject PyCredentialCacheContainer;
-typedef struct {
-       PyObject_HEAD
-       TALLOC_CTX *mem_ctx;
-       struct ccache_container *ccc;
-} PyCredentialCacheContainerObject;
 #define PyCredentials_Check(py_obj) PyObject_TypeCheck(py_obj, &PyCredentials)
 #define PyCredentials_AsCliCredentials(py_obj) pytalloc_get_type(py_obj, struct cli_credentials)
 #define cli_credentials_from_py_object(py_obj) (py_obj == Py_None)?cli_credentials_init_anon(NULL):PyCredentials_AsCliCredentials(py_obj)