Add close wappers for commit, tree, tag and blob In the same spirit that git_repository_lookup is no longer available, add wrappers so the users don't have to cast when closing their objects. Signed-off-by: Carlos Martín Nieto <cmn@elego.de>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
diff --git a/include/git2/blob.h b/include/git2/blob.h
index 3cd1467..c38a52f 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -53,6 +53,24 @@ GIT_INLINE(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git
}
/**
+ * Close an open blob
+ *
+ * This is a wrapper around git_object_close()
+ *
+ * IMPORTANT:
+ * It *is* necessary to call this method when you stop
+ * using a blob. Failure to do so will cause a memory leak.
+ *
+ * @param blob the blob to close
+ */
+
+GIT_INLINE(void) git_blob_close(git_blob *blob)
+{
+ return git_object_close((git_object *) blob);
+}
+
+
+/**
* Get a read-only buffer with the raw content of a blob.
*
* A pointer to the raw content of a blob is returned;
diff --git a/include/git2/commit.h b/include/git2/commit.h
index 8306eb1..d497324 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -54,6 +54,23 @@ GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, con
}
/**
+ * Close an open commit
+ *
+ * This is a wrapper around git_object_close()
+ *
+ * IMPORTANT:
+ * It *is* necessary to call this method when you stop
+ * using a commit. Failure to do so will cause a memory leak.
+ *
+ * @param commit the commit to close
+ */
+
+GIT_INLINE(void) git_commit_close(git_commit *commit)
+{
+ return git_object_close((git_object *) commit);
+}
+
+/**
* Get the id of a commit.
*
* @param commit a previously loaded commit.
diff --git a/include/git2/tag.h b/include/git2/tag.h
index c343f6b..845b205 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -53,6 +53,24 @@ GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oi
}
/**
+ * Close an open tag
+ *
+ * This is a wrapper around git_object_close()
+ *
+ * IMPORTANT:
+ * It *is* necessary to call this method when you stop
+ * using a tag. Failure to do so will cause a memory leak.
+ *
+ * @param tag the tag to close
+ */
+
+GIT_INLINE(void) git_tag_close(git_tag *tag)
+{
+ return git_object_close((git_object *) tag);
+}
+
+
+/**
* Get the id of a tag.
*
* @param tag a previously loaded tag.
diff --git a/include/git2/tree.h b/include/git2/tree.h
index ec2b516..cb959a7 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -53,6 +53,24 @@ GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git
}
/**
+ * Close an open tree
+ *
+ * This is a wrapper around git_object_close()
+ *
+ * IMPORTANT:
+ * It *is* necessary to call this method when you stop
+ * using a tree. Failure to do so will cause a memory leak.
+ *
+ * @param tree the tree to close
+ */
+
+GIT_INLINE(void) git_tree_close(git_tree *tree)
+{
+ return git_object_close((git_object *) tree);
+}
+
+
+/**
* Get the id of a tree.
*
* @param tree a previously loaded tree.