[libgit2-glib] Return copy of value in config match



commit 4508b9b3dd97b5988e6bd073ddb64a7ed7a3ba0a
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Mon Jan 20 13:56:13 2014 +0100

    Return copy of value in config match

 libgit2-glib/ggit-config.c |    9 +++++----
 libgit2-glib/ggit-config.h |    2 +-
 2 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/libgit2-glib/ggit-config.c b/libgit2-glib/ggit-config.c
index 69239ce..18639ff 100644
--- a/libgit2-glib/ggit-config.c
+++ b/libgit2-glib/ggit-config.c
@@ -674,7 +674,7 @@ typedef struct
        GRegex *regex;
        GMatchInfo *ret;
 
-       const gchar *value;
+       gchar *value;
 
        GgitConfigMatchCallback callback;
        gpointer user_data;
@@ -698,7 +698,8 @@ match_foreach (const gchar *name,
                }
                else
                {
-                       info->value = value;
+                       g_free (info->value);
+                       info->value = g_strdup (value);
 
                        /* Semi arbitrary error */
                        return GGIT_ERROR_EXISTS;
@@ -719,10 +720,10 @@ match_foreach (const gchar *name,
  * contain the match information if the return value is not %NULL, otherwise
  * @error will be set.
  *
- * Returns: (allow-none): the value of that matched configuration
+ * Returns: (allow-none) (transfer full): the value of that matched configuration
  *
  **/
-const gchar *
+gchar *
 ggit_config_match (GgitConfig  *config,
                    GRegex      *regex,
                    GMatchInfo **match_info,
diff --git a/libgit2-glib/ggit-config.h b/libgit2-glib/ggit-config.h
index 1c8459b..9d7d2d5 100644
--- a/libgit2-glib/ggit-config.h
+++ b/libgit2-glib/ggit-config.h
@@ -126,7 +126,7 @@ gboolean     ggit_config_foreach       (GgitConfig               *config,
                                         gpointer                  user_data,
                                         GError                  **error);
 
-const gchar *ggit_config_match         (GgitConfig               *config,
+gchar       *ggit_config_match         (GgitConfig               *config,
                                         GRegex                   *regex,
                                         GMatchInfo              **match_info,
                                         GError                  **error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]