
On Thu, Feb 26, 2015 at 15:17:17 +0100, Michal Privoznik wrote:
In order to hide the object internals (and use just accessors everywhere), lets store a pointer to the object, instead of object itself.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/test/test_driver.c | 106 ++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 55 deletions(-)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c index e2da1e2..90df0e7 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -101,7 +101,7 @@ struct _testConn { virDomainXMLOptionPtr xmlopt; virNodeInfo nodeInfo; virDomainObjListPtr domains; - virNetworkObjList networks; + virNetworkObjListPtr networks; virInterfaceObjList ifaces; bool transaction_running; virInterfaceObjList backupIfaces; @@ -115,7 +115,7 @@ struct _testConn { virObjectEventStatePtr eventState; }; typedef struct _testConn testConn; -typedef struct _testConn *testConnPtr; +typedef testConn *testConnPtr;
static testConn defaultConn; static int defaultConnections; @@ -724,7 +724,8 @@ testOpenDefault(virConnectPtr conn) if (!(privconn->eventState = virObjectEventStateNew())) goto error;
- if (!(privconn->domains = virDomainObjListNew())) + if (!(privconn->domains = virDomainObjListNew()) || + VIR_ALLOC(privconn->networks) < 0) goto error;
Since you are going to convert the network structure to an objec wouldn't it be better to add a constructor for the object right away instead of having to do it later once you hide the struct? Otherwise looks good. Peter