[libgit2-glib] Do not expose header length



commit caf62a5e9bb3febd7021ecfe85de7cc2e4add427
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Nov 23 14:55:22 2013 +0100

    Do not expose header length

 libgit2-glib/ggit-diff-hunk.c |   24 +++---------------------
 libgit2-glib/ggit-diff-hunk.h |    1 -
 2 files changed, 3 insertions(+), 22 deletions(-)
---
diff --git a/libgit2-glib/ggit-diff-hunk.c b/libgit2-glib/ggit-diff-hunk.c
index b568ade..3c7875d 100644
--- a/libgit2-glib/ggit-diff-hunk.c
+++ b/libgit2-glib/ggit-diff-hunk.c
@@ -31,8 +31,7 @@ struct _GgitDiffHunk {
        gint old_lines;
        gint new_start;
        gint new_lines;
-       gsize header_len;
-       gchar header[128];
+       gchar *header;
 };
 
 G_DEFINE_BOXED_TYPE (GgitDiffHunk, ggit_diff_hunk,
@@ -52,10 +51,8 @@ _ggit_diff_hunk_wrap (const git_diff_hunk *hunk)
        ghunk->old_lines = hunk->old_lines;
        ghunk->new_start = hunk->new_start;
        ghunk->new_lines = hunk->new_lines;
-       ghunk->header_len = hunk->header_len;
-
-       strncpy(ghunk->header, hunk->header, hunk->header_len);
 
+       ghunk->header = g_strndup (hunk->header, hunk->header_len);
        return ghunk;
 }
 
@@ -92,6 +89,7 @@ ggit_diff_hunk_unref (GgitDiffHunk *hunk)
 
        if (g_atomic_int_dec_and_test (&hunk->ref_count))
        {
+               g_free (hunk->header);
                g_slice_free (GgitDiffHunk, hunk);
        }
 }
@@ -161,22 +159,6 @@ ggit_diff_hunk_get_new_lines (GgitDiffHunk *hunk)
 }
 
 /**
- * ggit_diff_hunk_get_header_len:
- * @hunk: a #GgitDiffHunk.
- *
- * Gets the header length.
- *
- * Returns: the header length.
- */
-gsize
-ggit_diff_hunk_get_header_len (GgitDiffHunk *hunk)
-{
-       g_return_val_if_fail (hunk != NULL, 0);
-
-       return hunk->header_len;
-}
-
-/**
  * ggit_diff_hunk_get_content:
  * @hunk: a #GgitDiffHunk.
  *
diff --git a/libgit2-glib/ggit-diff-hunk.h b/libgit2-glib/ggit-diff-hunk.h
index 4d4b8e3..49aa66c 100644
--- a/libgit2-glib/ggit-diff-hunk.h
+++ b/libgit2-glib/ggit-diff-hunk.h
@@ -39,7 +39,6 @@ gchar           ggit_diff_hunk_get_old_start      (GgitDiffHunk        *hunk);
 gint            ggit_diff_hunk_get_old_lines      (GgitDiffHunk        *hunk);
 gint            ggit_diff_hunk_get_new_start      (GgitDiffHunk        *hunk);
 gint            ggit_diff_hunk_get_new_lines      (GgitDiffHunk        *hunk);
-gsize           ggit_diff_hunk_get_header_len     (GgitDiffHunk        *hunk);
 const gchar    *ggit_diff_hunk_get_header         (GgitDiffHunk        *hunk);
 
 G_END_DECLS


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