Commit c8ee52703b18b667981008a1f12fac993dee91ec

Patrick Steinhardt 2017-12-08T09:05:58

pack: rename `git_packfile_stream_free` The function `git_packfile_stream_free` frees all state of the packfile stream without freeing the structure itself. This naming makes it hard to spot whether it will try to free the pointer itself or not, causing potential future errors. Due to this reason, we have decided to name a function freeing state without freeing the actual struture a "dispose" function. Rename `git_packfile_stream_free` to `git_packfile_stream_dispose` as a first example following this rule.

diff --git a/src/indexer.c b/src/indexer.c
index c0976f2..89c546d 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -650,7 +650,7 @@ int git_indexer_append(git_indexer *idx, const void *data, size_t size, git_tran
 
 		/* We want to free the stream reasorces no matter what here */
 		idx->have_stream = 0;
-		git_packfile_stream_free(stream);
+		git_packfile_stream_dispose(stream);
 
 		if (error < 0)
 			goto on_error;
@@ -1137,7 +1137,7 @@ void git_indexer_free(git_indexer *idx)
 		return;
 
 	if (idx->have_stream)
-		git_packfile_stream_free(&idx->stream);
+		git_packfile_stream_dispose(&idx->stream);
 
 	git_vector_free_deep(&idx->objects);
 
diff --git a/src/pack.c b/src/pack.c
index 9ed3ec1..39c77a4 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -499,7 +499,7 @@ int git_packfile_resolve_header(
 		if ((error = git_packfile_stream_open(&stream, p, curpos)) < 0)
 			return error;
 		error = git_delta_read_header_fromstream(&base_size, size_p, &stream);
-		git_packfile_stream_free(&stream);
+		git_packfile_stream_dispose(&stream);
 		if (error < 0)
 			return error;
 	} else {
@@ -840,7 +840,7 @@ ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t 
 
 }
 
-void git_packfile_stream_free(git_packfile_stream *obj)
+void git_packfile_stream_dispose(git_packfile_stream *obj)
 {
 	inflateEnd(&obj->zstream);
 }
diff --git a/src/pack.h b/src/pack.h
index c0ca74f..e1d8d04 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -144,7 +144,7 @@ int git_packfile_unpack(git_rawobj *obj, struct git_pack_file *p, git_off_t *obj
 
 int git_packfile_stream_open(git_packfile_stream *obj, struct git_pack_file *p, git_off_t curpos);
 ssize_t git_packfile_stream_read(git_packfile_stream *obj, void *buffer, size_t len);
-void git_packfile_stream_free(git_packfile_stream *obj);
+void git_packfile_stream_dispose(git_packfile_stream *obj);
 
 git_off_t get_delta_base(struct git_pack_file *p, git_mwindow **w_curs,
 		git_off_t *curpos, git_otype type,