[Github-comments] [geany/geany-plugins] geanyctags: Use base path as relative to the project file path (#755)
Colomban Wendling
notifications at xxxxx
Thu Jun 14 15:30:50 UTC 2018
b4n requested changes on this pull request.
Leaks should be fixed.
> @@ -205,6 +205,26 @@ static gchar *generate_find_string(GeanyProject *prj)
}
+static const gchar *get_base_path(void)
+{
+ static gchar *ret = NULL;
+ GeanyProject *prj = geany_data->app->project;
+ gchar *project_dir_utf8;
+
+ if (!prj)
+ return NULL;
+
+ if (g_path_is_absolute(prj->base_path))
+ return prj->base_path;
+
+ g_free(ret);
not useful as it's always `NULL` at this point
> @@ -205,6 +205,26 @@ static gchar *generate_find_string(GeanyProject *prj)
}
+static const gchar *get_base_path(void)
this function has a leaky semantic: it returns *either* `prj->base_path` *or* an allocated buffer. The caller must then free conditionally, which is tricky at best.
> @@ -236,7 +256,7 @@ on_generate_tags(GtkMenuItem *menuitem, gpointer user_data)
tag_filename, "\"", NULL);
#endif
- spawn_cmd(cmd, prj->base_path);
+ spawn_cmd(cmd, get_base_path());
leaks when `prj->base_path` is relative
> @@ -421,7 +441,7 @@ static void find_tags(const gchar *name, gboolean declaration, gboolean case_sen
return;
msgwin_clear_tab(MSG_MESSAGE);
- msgwin_set_messages_dir(prj->base_path);
+ msgwin_set_messages_dir(get_base_path());
same
> @@ -445,7 +465,7 @@ static void find_tags(const gchar *name, gboolean declaration, gboolean case_sen
if (!filter_tag(&entry, name_pat, declaration, case_sensitive))
{
- path = g_build_filename(prj->base_path, entry.file, NULL);
+ path = g_build_filename(get_base_path(), entry.file, NULL);
more
> @@ -456,7 +476,7 @@ static void find_tags(const gchar *name, gboolean declaration, gboolean case_sen
if (!filter_tag(&entry, name_pat, declaration, case_sensitive))
{
if (!path)
- path = g_build_filename(prj->base_path, entry.file, NULL);
+ path = g_build_filename(get_base_path(), entry.file, NULL);
and… it's me again :grin:
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany-plugins/pull/755#pullrequestreview-128843147
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20180614/7fd61f0a/attachment-0001.html>
More information about the Github-comments
mailing list