[libgit2-glib] Make ggit_blob_get_raw_content bindings friendly
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] Make ggit_blob_get_raw_content bindings friendly
- Date: Tue, 17 Jul 2012 14:48:09 +0000 (UTC)
commit 94835550368280b6ef00e1626850f88aaa3d5dc2
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Tue Jul 17 16:48:03 2012 +0200
Make ggit_blob_get_raw_content bindings friendly
libgit2-glib/ggit-blob.c | 37 +++++++++++++------------------------
libgit2-glib/ggit-blob.h | 5 ++---
2 files changed, 15 insertions(+), 27 deletions(-)
---
diff --git a/libgit2-glib/ggit-blob.c b/libgit2-glib/ggit-blob.c
index 2b7c647..cf537e3 100644
--- a/libgit2-glib/ggit-blob.c
+++ b/libgit2-glib/ggit-blob.c
@@ -55,6 +55,7 @@ _ggit_blob_wrap (git_blob *blob,
/**
* ggit_blob_get_raw_content:
* @blob: a #GgitBlob.
+ * @length: (out) (allow-none): return value of the length of the data.
*
* Gets a read-only buffer with the raw contents of @blob.
*
@@ -63,10 +64,13 @@ _ggit_blob_wrap (git_blob *blob,
* not be free'd. The pointer may be invalidated at a later
* time.
*
- * Returns: (transfer none): the contents or %NULL if @blob has no contents.
- */
-gconstpointer
-ggit_blob_get_raw_content (GgitBlob *blob)
+ * Returns: (array length=length) (element-type guchar): the blob content or
+ * %NULL if the blob does not have any content.
+ *
+ **/
+const guchar *
+ggit_blob_get_raw_content (GgitBlob *blob,
+ gsize *length)
{
git_blob *b;
@@ -74,27 +78,12 @@ ggit_blob_get_raw_content (GgitBlob *blob)
b = _ggit_native_get (blob);
- return git_blob_rawcontent (b);
-}
-
-/**
- * ggit_blob_get_raw_size:
- * @blob: a #GgitBlob.
- *
- * Gets the size in bytes of the contents of @blob.
- *
- * Returns: the size in bytes.
- */
-gsize
-ggit_blob_get_raw_size (GgitBlob *blob)
-{
- git_blob *b;
-
- g_return_val_if_fail (GGIT_IS_BLOB (blob), 0);
-
- b = _ggit_native_get (blob);
+ if (length != NULL)
+ {
+ *length = git_blob_rawsize (b);
+ }
- return git_blob_rawsize (b);
+ return (const guchar *)git_blob_rawcontent (b);
}
/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-blob.h b/libgit2-glib/ggit-blob.h
index 416948e..8ee5008 100644
--- a/libgit2-glib/ggit-blob.h
+++ b/libgit2-glib/ggit-blob.h
@@ -63,9 +63,8 @@ GType ggit_blob_get_type (void) G_GNUC_CONST;
GgitBlob *_ggit_blob_wrap (git_blob *blob,
gboolean owned);
-gconstpointer ggit_blob_get_raw_content (GgitBlob *blob);
-
-gsize ggit_blob_get_raw_size (GgitBlob *blob);
+const guchar *ggit_blob_get_raw_content (GgitBlob *blob,
+ gsize *length);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]