[Spice-devel] [PATCH 4/4] vdagent: Use glib's commandline parser
Victor Toso
victortoso at redhat.com
Tue May 16 16:37:00 UTC 2017
On Tue, May 16, 2017 at 12:32:35PM -0400, Frediano Ziglio wrote:
> >
> > On Tue, May 16, 2017 at 06:07:00PM +0200, Victor Toso wrote:
> > > Hi,
> > >
> > > On Tue, May 16, 2017 at 05:29:57PM +0200, Christophe Fergeau wrote:
> > > > On Fri, May 12, 2017 at 01:19:40PM +0200, Victor Toso wrote:
> > > > > From: Victor Toso <me at victortoso.com>
> > > > >
> > > > > As we already depend on glib, let's remove code that glib can take
> > > > > care. In this case, we don't need to handle commandline parsing
> > > > > ourselves.
> > > > >
> > > > > In regard the global variables:
> > > > >
> > > > > * static const char * -> static char * [only paths]
> > > >
> > > > Ideally, they would need to be g_free'd at some point, dunno if you
> > > > have looked at doing that, but it was inconvenient, or if this was
> > > > forgotten?
> > >
> > > tbh, I thought GOptionEntry wouldn't take a const gchar *. I'll move it
> > > to const again.
> >
> > I don't think it would accept a const gchar *, see
> > https://developer.gnome.org/glib/stable/glib-Commandline-option-parser.html#GOptionEntry
> > « If arg type is G_OPTION_ARG_STRING or G_OPTION_ARG_FILENAME, the
> > location will contain a newly allocated string if the option was given.
> > That string needs to be freed by the callee using g_free(). »
> >
> > Christophe
> >
>
> Yes, if the option is given. If not calling something like g_free("constant") will warn
> and if not probably crash.
Initializing with it NULL should avoid any problems, I think.
> No, don't accept a const char*, but you have to pass a pointer to that
> which is a const char** which is accepted (or at least should be).
>
> Frediano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170516/96bab47a/attachment.sig>
More information about the Spice-devel
mailing list