On Thu, Feb 26, 2015 at 15:17:28 +0100, Michal Privoznik wrote: > Well, one day this will be self-locking object, but not today. > But lets prepare the code for that! Moreover, > virNetworkObjListFree() is no longer needed, so turn it into > virNetworkObjListDispose(). > > Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> > --- > cfg.mk | 1 - > src/conf/network_conf.c | 53 +++++++++++++++++++++++++++++---------- > src/conf/network_conf.h | 11 ++++---- > src/libvirt_private.syms | 2 +- > src/network/bridge_driver.c | 5 ++-- > src/parallels/parallels_driver.c | 2 +- > src/parallels/parallels_network.c | 2 +- > src/test/test_driver.c | 13 ++++------ > 8 files changed, 56 insertions(+), 33 deletions(-) > > diff --git a/cfg.mk b/cfg.mk > index d72b039..07a794a 100644 > --- a/cfg.mk > +++ b/cfg.mk > @@ -250,7 +250,6 @@ useless_free_options = \ > # n virNetworkFree (returns int) > # n virNetworkFreeName (returns int) > # y virNetworkObjFree > -# n virNetworkObjListFree FIXME > # n virNodeDevCapsDefFree FIXME > # y virNodeDeviceDefFree > # n virNodeDeviceFree (returns int) > diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c > index 24a5f7c..4efad43 100644 > --- a/src/conf/network_conf.c > +++ b/src/conf/network_conf.c > @@ -73,17 +73,33 @@ VIR_ENUM_IMPL(virNetworkForwardDriverName, > VIR_ENUM_IMPL(virNetworkTaint, VIR_NETWORK_TAINT_LAST, > "hook-script"); > > -bool > -virNetworkObjTaint(virNetworkObjPtr obj, > - virNetworkTaintFlags taint) I don't see a reason to move this function ... > +static virClassPtr virNetworkObjListClass; > +static void virNetworkObjListDispose(void *obj); > + > +static int virNetworkObjOnceInit(void) > +{ > + if (!(virNetworkObjListClass = virClassNew(virClassForObject(), > + "virNetworkObjList", > + sizeof(virNetworkObjList), > + virNetworkObjListDispose))) > + return -1; > + return 0; > +} > + > + > +VIR_ONCE_GLOBAL_INIT(virNetworkObj) > + > +virNetworkObjListPtr virNetworkObjListNew(void) > { > - unsigned int flag = (1 << taint); > + virNetworkObjListPtr nets; > + > + if (virNetworkObjInitialize() < 0) > + return NULL; > > - if (obj->taint & flag) > - return false; > + if (!(nets = virObjectNew(virNetworkObjListClass))) > + return NULL; > > - obj->taint |= flag; > - return true; > + return nets; > } > > virNetworkObjPtr virNetworkObjFindByUUID(virNetworkObjListPtr nets, > @@ -116,6 +132,19 @@ virNetworkObjPtr virNetworkObjFindByName(virNetworkObjListPtr nets, > return NULL; > } > > +bool > +virNetworkObjTaint(virNetworkObjPtr obj, > + virNetworkTaintFlags taint) Here. > +{ > + unsigned int flag = (1 << taint); > + > + if (obj->taint & flag) > + return false; > + > + obj->taint |= flag; > + return true; > +} > + > > static void > virPortGroupDefClear(virPortGroupDefPtr def) > @@ -275,18 +304,16 @@ void virNetworkObjFree(virNetworkObjPtr net) > VIR_FREE(net); > } > > -void virNetworkObjListFree(virNetworkObjListPtr nets) > +static void > +virNetworkObjListDispose(void *obj) > { > + virNetworkObjListPtr nets = obj; > size_t i; > > - if (!nets) > - return; > - > for (i = 0; i < nets->count; i++) > virNetworkObjFree(nets->objs[i]); > > VIR_FREE(nets->objs); > - nets->count = 0; > } > > /* > diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h > index 164fb1a..5725258 100644 > --- a/src/conf/network_conf.h > +++ b/src/conf/network_conf.h > @@ -40,6 +40,7 @@ > # include "device_conf.h" > # include "virbitmap.h" > # include "networkcommon_conf.h" > +# include "virobject.h" > > typedef enum { > VIR_NETWORK_FORWARD_NONE = 0, > @@ -277,6 +278,8 @@ struct _virNetworkObj { > typedef struct _virNetworkObjList virNetworkObjList; > typedef virNetworkObjList *virNetworkObjListPtr; > struct _virNetworkObjList { > + virObject parent; > + > size_t count; > virNetworkObjPtr *objs; > }; > @@ -298,19 +301,17 @@ virNetworkObjIsActive(const virNetworkObj *net) > return net->active; > } > > -bool virNetworkObjTaint(virNetworkObjPtr obj, > - virNetworkTaintFlags taint); Nor this definition ... > +virNetworkObjListPtr virNetworkObjListNew(void); > > virNetworkObjPtr virNetworkObjFindByUUID(virNetworkObjListPtr nets, > const unsigned char *uuid); > virNetworkObjPtr virNetworkObjFindByName(virNetworkObjListPtr nets, > const char *name); > - > +bool virNetworkObjTaint(virNetworkObjPtr obj, > + virNetworkTaintFlags taint); Here. > > void virNetworkDefFree(virNetworkDefPtr def); > void virNetworkObjFree(virNetworkObjPtr net); > -void virNetworkObjListFree(virNetworkObjListPtr nets); > - > > typedef bool (*virNetworkObjListFilter)(virConnectPtr conn, > virNetworkDefPtr def); ACK if you don't touch virNetworkObjTaint. Peter
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list