From 1f5dbe969198be9eea0fea09a07b3f46b323f81d Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Fri, 29 Apr 2016 15:53:38 +0200 Subject: fixup! g-ir-inspect: Inspect GI typelibs Signed-off-by: Igor Gnatenko --- tools/g-ir-inspect.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/tools/g-ir-inspect.c b/tools/g-ir-inspect.c index dc15bcb4..7223af1f 100644 --- a/tools/g-ir-inspect.c +++ b/tools/g-ir-inspect.c @@ -23,8 +23,6 @@ #include #include -G_DEFINE_AUTOPTR_CLEANUP_FUNC(GITypelib, g_typelib_free) - static void print_shlibs (const gchar *namespace) { @@ -35,9 +33,10 @@ print_shlibs (const gchar *namespace) if (shlibs && shlibs[0] != '\0') { /* shlibs is a comma-separated list of libraries */ - g_auto(GStrv) libs = g_strsplit (shlibs, ",", -1); - for (i; libs[i]; i++) + GStrv libs = g_strsplit (shlibs, ",", -1); + for (i = 0; libs[i]; i++) g_print ("shlib: %s\n", libs[i]); + g_strfreev (libs); } } @@ -47,11 +46,12 @@ print_typelibs (const gchar *namespace) guint i = 0; /* Finding all the typelib-based Requires */ - g_auto(GStrv) deps = g_irepository_get_dependencies (NULL, namespace); + GStrv deps = g_irepository_get_dependencies (NULL, namespace); if (deps) { - for (i; deps[i]; i++) + for (i = 0; deps[i]; i++) g_print ("typelib: %s\n", deps[i]); + g_strfreev (deps); } } @@ -59,13 +59,15 @@ gint main (gint argc, gchar *argv[]) { - g_autoptr(GError) error = NULL; - g_autoptr(GITypelib) typelib = NULL; + gint status = EXIT_SUCCESS; + + GError *error = NULL; + GITypelib *typelib = NULL; - g_autofree gchar *version = NULL; + gchar *version = NULL; gboolean opt_shlibs = FALSE; gboolean opt_typelibs = FALSE; - g_auto(GStrv) namespaces = NULL; + GStrv namespaces = NULL; const gchar *namespace = NULL; const GOptionEntry options[] = { { "version", 0, 0, G_OPTION_ARG_STRING, &version, "Version", "VERSION" }, @@ -79,34 +81,39 @@ main (gint argc, g_option_context_add_main_entries (context, options, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { + status = EXIT_FAILURE; g_printerr ("Failed to parse command line options: %s\n", error->message); - return EXIT_FAILURE; + goto out; } if (!namespaces) { + status = EXIT_FAILURE; g_printerr ("Please specify at least one namespace\n"); - return EXIT_FAILURE; + goto out; } if (g_strv_length (namespaces) > 1) { + status = EXIT_FAILURE; g_printerr ("Please specify only one namespace\n"); - return EXIT_FAILURE; + goto out; } namespace = namespaces[0]; if (!opt_shlibs && !opt_typelibs) { + status = EXIT_FAILURE; g_printerr ("Please specify --print-shlibs, --print-typelibs or both.\n"); - return EXIT_FAILURE; + goto out; } typelib = g_irepository_require (NULL, namespace, version, 0, &error); if (!typelib) { + status = EXIT_FAILURE; g_printerr ("Failed to load typelib: %s\n", error->message); - return EXIT_FAILURE; + goto out; } if (opt_shlibs) @@ -114,5 +121,13 @@ main (gint argc, if (opt_typelibs) print_typelibs (namespace); - return EXIT_SUCCESS; +out: + if (error) + g_error_free (error); + if (typelib) + g_typelib_free (typelib); + g_strfreev (namespaces); + g_free (version); + + return status; } -- cgit v1.2.1