On Fri, May 04, 2018 at 17:25:33 +0800, Lin Ma wrote: > Signed-off-by: Lin Ma <lma@xxxxxxxx> > --- > tools/virsh-completer.c | 36 ++++++++++++++++++++++++++++++++++++ > tools/virsh-completer.h | 3 +++ > tools/virsh-domain.c | 1 + > 3 files changed, 40 insertions(+) > > diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c > index e3b8234b41..a188a8d7ab 100644 > --- a/tools/virsh-completer.c > +++ b/tools/virsh-completer.c > @@ -30,6 +30,7 @@ > #include "viralloc.h" > #include "virstring.h" > #include "virxml.h" > +extern const char *virDomainEventGetName(int event); Please don't use externs. If you need the function export it. > > > char ** > @@ -522,3 +523,38 @@ virshSnapshotNameCompleter(vshControl *ctl, > virshDomainFree(dom); > return NULL; > } > + > + > +char ** > +virshEventNameCompleter(vshControl *ctl, > + const vshCmd *cmd ATTRIBUTE_UNUSED, > + unsigned int flags) > +{ > + virshControlPtr priv = ctl->privData; > + size_t i = 0; > + char **ret = NULL; > + > + virCheckFlags(0, NULL); > + > + if (!priv->conn || virConnectIsAlive(priv->conn) <= 0) > + return NULL; > + > + if (VIR_ALLOC_N(ret, VIR_DOMAIN_EVENT_ID_LAST + 1) < 0) > + goto error; > + > + for (i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) { > + const char *name = virDomainEventGetName(i); > + > + if (name == NULL) > + goto error; > + > + if (VIR_STRDUP(ret[i], name) < 0) > + goto error; > + } > + > + return ret; > + > +error: > + VIR_FREE(ret); This does not free the members in ret allocated by the strdup above. > + return NULL; > +}
Attachment:
signature.asc
Description: PGP signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list