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.
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
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,