Commit 52e27b840437d1a374c014a04787d0962f05a4f0

Edward Thomson 2018-10-10T12:42:54

reader: free is unused and unnecessary None of the reader implementations actually allocate anything themselves, so they don't need a free function. Remove it.

diff --git a/src/reader.c b/src/reader.c
index 2cdd0a1..5de731b 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -47,11 +47,6 @@ done:
 	return error;
 }
 
-static void tree_reader_free(git_reader *_reader)
-{
-	GIT_UNUSED(_reader);
-}
-
 int git_reader_for_tree(git_reader **out, git_tree *tree)
 {
 	tree_reader *reader;
@@ -62,7 +57,6 @@ int git_reader_for_tree(git_reader **out, git_tree *tree)
 	GITERR_CHECK_ALLOC(reader);
 
 	reader->reader.read = tree_reader_read;
-	reader->reader.free = tree_reader_free;
 	reader->tree = tree;
 
 	*out = (git_reader *)reader;
@@ -129,11 +123,6 @@ done:
 	return error;
 }
 
-static void workdir_reader_free(git_reader *_reader)
-{
-	GIT_UNUSED(_reader);
-}
-
 int git_reader_for_workdir(
 	git_reader **out,
 	git_repository *repo,
@@ -148,7 +137,6 @@ int git_reader_for_workdir(
 	GITERR_CHECK_ALLOC(reader);
 
 	reader->reader.read = workdir_reader_read;
-	reader->reader.free = workdir_reader_free;
 	reader->repo = repo;
 
 	if (validate_index &&
@@ -196,11 +184,6 @@ done:
 	return error;
 }
 
-static void index_reader_free(git_reader *_reader)
-{
-	GIT_UNUSED(_reader);
-}
-
 int git_reader_for_index(
 	git_reader **out,
 	git_repository *repo,
@@ -215,7 +198,6 @@ int git_reader_for_index(
 	GITERR_CHECK_ALLOC(reader);
 
 	reader->reader.read = index_reader_read;
-	reader->reader.free = index_reader_free;
 	reader->repo = repo;
 
 	if (index) {
@@ -247,6 +229,5 @@ void git_reader_free(git_reader *reader)
 	if (!reader)
 		return;
 
-	reader->free(reader);
 	git__free(reader);
 }
diff --git a/src/reader.h b/src/reader.h
index e1d9068..f9dd6b5 100644
--- a/src/reader.h
+++ b/src/reader.h
@@ -26,7 +26,6 @@ typedef struct git_reader git_reader;
  */
 struct git_reader {
 	int (*read)(git_buf *out, git_oid *out_oid, git_reader *reader, const char *filename);
-	void (*free)(git_reader *reader);
 };
 
 /**