Commit 45e79e37 by Vicent Marti

Rename all `_close` methods

There's no difference between `_free` and `_close` semantics: keep
everything with the same name to avoid confusions.
parent 9462c471
...@@ -107,7 +107,7 @@ int main (int argc, char** argv) ...@@ -107,7 +107,7 @@ int main (int argc, char** argv)
// For proper memory management, close the object when you are done with it or it will leak // For proper memory management, close the object when you are done with it or it will leak
// memory. // memory.
git_odb_object_close(obj); git_odb_object_free(obj);
// #### Raw Object Writing // #### Raw Object Writing
...@@ -167,12 +167,12 @@ int main (int argc, char** argv) ...@@ -167,12 +167,12 @@ int main (int argc, char** argv)
git_commit_parent(&parent, commit, p); git_commit_parent(&parent, commit, p);
git_oid_fmt(out, git_commit_id(parent)); git_oid_fmt(out, git_commit_id(parent));
printf("Parent: %s\n", out); printf("Parent: %s\n", out);
git_commit_close(parent); git_commit_free(parent);
} }
// Don't forget to close the object to prevent memory leaks. You will have to do this for // Don't forget to close the object to prevent memory leaks. You will have to do this for
// all the objects you open and parse. // all the objects you open and parse.
git_commit_close(commit); git_commit_free(commit);
// #### Writing Commits // #### Writing Commits
// //
...@@ -243,7 +243,7 @@ int main (int argc, char** argv) ...@@ -243,7 +243,7 @@ int main (int argc, char** argv)
tmessage = git_tag_message(tag); // "tag message\n" tmessage = git_tag_message(tag); // "tag message\n"
printf("Tag Message: %s\n", tmessage); printf("Tag Message: %s\n", tmessage);
git_commit_close(commit); git_commit_free(commit);
// #### Tree Parsing // #### Tree Parsing
// [Tree parsing][tp] is a bit different than the other objects, in that we have a subtype which is the // [Tree parsing][tp] is a bit different than the other objects, in that we have a subtype which is the
...@@ -276,7 +276,7 @@ int main (int argc, char** argv) ...@@ -276,7 +276,7 @@ int main (int argc, char** argv)
git_tree_entry_2object(&objt, repo, entry); // blob git_tree_entry_2object(&objt, repo, entry); // blob
// Remember to close the looked-up object once you are done using it // Remember to close the looked-up object once you are done using it
git_object_close(objt); git_object_free(objt);
// #### Blob Parsing // #### Blob Parsing
// //
...@@ -340,7 +340,7 @@ int main (int argc, char** argv) ...@@ -340,7 +340,7 @@ int main (int argc, char** argv)
cmsg = git_commit_message(wcommit); cmsg = git_commit_message(wcommit);
cauth = git_commit_author(wcommit); cauth = git_commit_author(wcommit);
printf("%s (%s)\n", cmsg, cauth->email); printf("%s (%s)\n", cmsg, cauth->email);
git_commit_close(wcommit); git_commit_free(wcommit);
} }
// Like the other objects, be sure to free the revwalker when you're done to prevent memory leaks. // Like the other objects, be sure to free the revwalker when you're done to prevent memory leaks.
......
...@@ -54,7 +54,7 @@ GIT_INLINE(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, co ...@@ -54,7 +54,7 @@ GIT_INLINE(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, co
/** /**
* Close an open blob * Close an open blob
* *
* This is a wrapper around git_object_close() * This is a wrapper around git_object_free()
* *
* IMPORTANT: * IMPORTANT:
* It *is* necessary to call this method when you stop * It *is* necessary to call this method when you stop
...@@ -63,9 +63,9 @@ GIT_INLINE(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, co ...@@ -63,9 +63,9 @@ GIT_INLINE(int) git_blob_lookup_prefix(git_blob **blob, git_repository *repo, co
* @param blob the blob to close * @param blob the blob to close
*/ */
GIT_INLINE(void) git_blob_close(git_blob *blob) GIT_INLINE(void) git_blob_free(git_blob *blob)
{ {
git_object_close((git_object *) blob); git_object_free((git_object *) blob);
} }
......
...@@ -56,7 +56,7 @@ GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *re ...@@ -56,7 +56,7 @@ GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *re
/** /**
* Close an open commit * Close an open commit
* *
* This is a wrapper around git_object_close() * This is a wrapper around git_object_free()
* *
* IMPORTANT: * IMPORTANT:
* It *is* necessary to call this method when you stop * It *is* necessary to call this method when you stop
...@@ -65,9 +65,9 @@ GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *re ...@@ -65,9 +65,9 @@ GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *re
* @param commit the commit to close * @param commit the commit to close
*/ */
GIT_INLINE(void) git_commit_close(git_commit *commit) GIT_INLINE(void) git_commit_free(git_commit *commit)
{ {
git_object_close((git_object *) commit); git_object_free((git_object *) commit);
} }
/** /**
......
...@@ -24,7 +24,7 @@ GIT_BEGIN_DECL ...@@ -24,7 +24,7 @@ GIT_BEGIN_DECL
* Lookup a reference to one of the objects in a repostory. * Lookup a reference to one of the objects in a repostory.
* *
* The generated reference is owned by the repository and * The generated reference is owned by the repository and
* should be closed with the `git_object_close` method * should be closed with the `git_object_free` method
* instead of free'd manually. * instead of free'd manually.
* *
* The 'type' parameter must match the type of the object * The 'type' parameter must match the type of the object
...@@ -56,7 +56,7 @@ GIT_EXTERN(int) git_object_lookup( ...@@ -56,7 +56,7 @@ GIT_EXTERN(int) git_object_lookup(
* the prefix; otherwise the method will fail. * the prefix; otherwise the method will fail.
* *
* The generated reference is owned by the repository and * The generated reference is owned by the repository and
* should be closed with the `git_object_close` method * should be closed with the `git_object_free` method
* instead of free'd manually. * instead of free'd manually.
* *
* The 'type' parameter must match the type of the object * The 'type' parameter must match the type of the object
...@@ -123,7 +123,7 @@ GIT_EXTERN(git_repository *) git_object_owner(const git_object *obj); ...@@ -123,7 +123,7 @@ GIT_EXTERN(git_repository *) git_object_owner(const git_object *obj);
* *
* @param object the object to close * @param object the object to close
*/ */
GIT_EXTERN(void) git_object_close(git_object *object); GIT_EXTERN(void) git_object_free(git_object *object);
/** /**
* Convert an object type to it's string representation. * Convert an object type to it's string representation.
......
...@@ -282,7 +282,7 @@ GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type) ...@@ -282,7 +282,7 @@ GIT_EXTERN(int) git_odb_hashfile(git_oid *out, const char *path, git_otype type)
* *
* @param object object to close * @param object object to close
*/ */
GIT_EXTERN(void) git_odb_object_close(git_odb_object *object); GIT_EXTERN(void) git_odb_object_free(git_odb_object *object);
/** /**
* Return the OID of an ODB object * Return the OID of an ODB object
......
...@@ -75,7 +75,7 @@ GIT_EXTERN(int) git_repository_discover( ...@@ -75,7 +75,7 @@ GIT_EXTERN(int) git_repository_discover(
* *
* Note that after a repository is free'd, all the objects it has spawned * Note that after a repository is free'd, all the objects it has spawned
* will still exist until they are manually closed by the user * will still exist until they are manually closed by the user
* with `git_object_close`, but accessing any of the attributes of * with `git_object_free`, but accessing any of the attributes of
* an object without a backing repository will result in undefined * an object without a backing repository will result in undefined
* behavior * behavior
* *
......
...@@ -54,7 +54,7 @@ GIT_INLINE(int) git_tag_lookup_prefix(git_tag **tag, git_repository *repo, const ...@@ -54,7 +54,7 @@ GIT_INLINE(int) git_tag_lookup_prefix(git_tag **tag, git_repository *repo, const
/** /**
* Close an open tag * Close an open tag
* *
* This is a wrapper around git_object_close() * This is a wrapper around git_object_free()
* *
* IMPORTANT: * IMPORTANT:
* It *is* necessary to call this method when you stop * It *is* necessary to call this method when you stop
...@@ -63,9 +63,9 @@ GIT_INLINE(int) git_tag_lookup_prefix(git_tag **tag, git_repository *repo, const ...@@ -63,9 +63,9 @@ GIT_INLINE(int) git_tag_lookup_prefix(git_tag **tag, git_repository *repo, const
* @param tag the tag to close * @param tag the tag to close
*/ */
GIT_INLINE(void) git_tag_close(git_tag *tag) GIT_INLINE(void) git_tag_free(git_tag *tag)
{ {
git_object_close((git_object *) tag); git_object_free((git_object *) tag);
} }
......
...@@ -54,7 +54,7 @@ GIT_INLINE(int) git_tree_lookup_prefix(git_tree **tree, git_repository *repo, co ...@@ -54,7 +54,7 @@ GIT_INLINE(int) git_tree_lookup_prefix(git_tree **tree, git_repository *repo, co
/** /**
* Close an open tree * Close an open tree
* *
* This is a wrapper around git_object_close() * This is a wrapper around git_object_free()
* *
* IMPORTANT: * IMPORTANT:
* It *is* necessary to call this method when you stop * It *is* necessary to call this method when you stop
...@@ -63,9 +63,9 @@ GIT_INLINE(int) git_tree_lookup_prefix(git_tree **tree, git_repository *repo, co ...@@ -63,9 +63,9 @@ GIT_INLINE(int) git_tree_lookup_prefix(git_tree **tree, git_repository *repo, co
* @param tree the tree to close * @param tree the tree to close
*/ */
GIT_INLINE(void) git_tree_close(git_tree *tree) GIT_INLINE(void) git_tree_free(git_tree *tree)
{ {
git_object_close((git_object *) tree); git_object_free((git_object *) tree);
} }
...@@ -273,7 +273,7 @@ GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_tr ...@@ -273,7 +273,7 @@ GIT_EXTERN(int) git_treebuilder_write(git_oid *oid, git_repository *repo, git_tr
* relative path. * relative path.
* *
* The returned tree is owned by the repository and * The returned tree is owned by the repository and
* should be closed with the `git_object_close` method. * should be closed with the `git_object_free` method.
* *
* @param subtree Pointer where to store the subtree * @param subtree Pointer where to store the subtree
* @param root A previously loaded tree which will be the root of the relative path * @param root A previously loaded tree which will be the root of the relative path
......
...@@ -26,7 +26,7 @@ size_t git_blob_rawsize(git_blob *blob) ...@@ -26,7 +26,7 @@ size_t git_blob_rawsize(git_blob *blob)
void git_blob__free(git_blob *blob) void git_blob__free(git_blob *blob)
{ {
git_odb_object_close(blob->odb_object); git_odb_object_free(blob->odb_object);
git__free(blob); git__free(blob);
} }
......
...@@ -109,7 +109,7 @@ int git_object_lookup_prefix( ...@@ -109,7 +109,7 @@ int git_object_lookup_prefix(
object = git_cache_get(&repo->objects, id); object = git_cache_get(&repo->objects, id);
if (object != NULL) { if (object != NULL) {
if (type != GIT_OBJ_ANY && type != object->type) { if (type != GIT_OBJ_ANY && type != object->type) {
git_object_close(object); git_object_free(object);
return git__throw(GIT_EINVALIDTYPE, return git__throw(GIT_EINVALIDTYPE,
"Failed to lookup object. " "Failed to lookup object. "
"The given type does not match the type on the ODB"); "The given type does not match the type on the ODB");
...@@ -151,7 +151,7 @@ int git_object_lookup_prefix( ...@@ -151,7 +151,7 @@ int git_object_lookup_prefix(
return git__rethrow(error, "Failed to lookup object"); return git__rethrow(error, "Failed to lookup object");
if (type != GIT_OBJ_ANY && type != odb_obj->raw.type) { if (type != GIT_OBJ_ANY && type != odb_obj->raw.type) {
git_odb_object_close(odb_obj); git_odb_object_free(odb_obj);
return git__throw(GIT_EINVALIDTYPE, "Failed to lookup object. The given type does not match the type on the ODB"); return git__throw(GIT_EINVALIDTYPE, "Failed to lookup object. The given type does not match the type on the ODB");
} }
...@@ -185,7 +185,7 @@ int git_object_lookup_prefix( ...@@ -185,7 +185,7 @@ int git_object_lookup_prefix(
break; break;
} }
git_odb_object_close(odb_obj); git_odb_object_free(odb_obj);
if (error < GIT_SUCCESS) { if (error < GIT_SUCCESS) {
git_object__free(object); git_object__free(object);
...@@ -229,7 +229,7 @@ void git_object__free(void *_obj) ...@@ -229,7 +229,7 @@ void git_object__free(void *_obj)
} }
} }
void git_object_close(git_object *object) void git_object_free(git_object *object)
{ {
if (object == NULL) if (object == NULL)
return; return;
......
...@@ -108,7 +108,7 @@ git_otype git_odb_object_type(git_odb_object *object) ...@@ -108,7 +108,7 @@ git_otype git_odb_object_type(git_odb_object *object)
return object->raw.type; return object->raw.type;
} }
void git_odb_object_close(git_odb_object *object) void git_odb_object_free(git_odb_object *object)
{ {
git_cached_obj_decref((git_cached_obj *)object, &free_odb_object); git_cached_obj_decref((git_cached_obj *)object, &free_odb_object);
} }
...@@ -446,7 +446,7 @@ int git_odb_exists(git_odb *db, const git_oid *id) ...@@ -446,7 +446,7 @@ int git_odb_exists(git_odb *db, const git_oid *id)
assert(db && id); assert(db && id);
if ((object = git_cache_get(&db->cache, id)) != NULL) { if ((object = git_cache_get(&db->cache, id)) != NULL) {
git_odb_object_close(object); git_odb_object_free(object);
return 1; return 1;
} }
...@@ -472,7 +472,7 @@ int git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git ...@@ -472,7 +472,7 @@ int git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git
if ((object = git_cache_get(&db->cache, id)) != NULL) { if ((object = git_cache_get(&db->cache, id)) != NULL) {
*len_p = object->raw.len; *len_p = object->raw.len;
*type_p = object->raw.type; *type_p = object->raw.type;
git_odb_object_close(object); git_odb_object_free(object);
return GIT_SUCCESS; return GIT_SUCCESS;
} }
...@@ -497,7 +497,7 @@ int git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git ...@@ -497,7 +497,7 @@ int git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git
*len_p = object->raw.len; *len_p = object->raw.len;
*type_p = object->raw.type; *type_p = object->raw.type;
git_odb_object_close(object); git_odb_object_free(object);
} }
return GIT_SUCCESS; return GIT_SUCCESS;
......
...@@ -686,7 +686,7 @@ static int packed_find_peel(git_repository *repo, struct packref *ref) ...@@ -686,7 +686,7 @@ static int packed_find_peel(git_repository *repo, struct packref *ref)
*/ */
} }
git_object_close(object); git_object_free(object);
return GIT_SUCCESS; return GIT_SUCCESS;
} }
......
...@@ -230,12 +230,12 @@ static int commit_parse(git_revwalk *walk, commit_object *commit) ...@@ -230,12 +230,12 @@ static int commit_parse(git_revwalk *walk, commit_object *commit)
return git__rethrow(error, "Failed to parse commit. Can't read object"); return git__rethrow(error, "Failed to parse commit. Can't read object");
if (obj->raw.type != GIT_OBJ_COMMIT) { if (obj->raw.type != GIT_OBJ_COMMIT) {
git_odb_object_close(obj); git_odb_object_free(obj);
return git__throw(GIT_EOBJTYPE, "Failed to parse commit. Object is no commit object"); return git__throw(GIT_EOBJTYPE, "Failed to parse commit. Object is no commit object");
} }
error = commit_quick_parse(walk, commit, &obj->raw); error = commit_quick_parse(walk, commit, &obj->raw);
git_odb_object_close(obj); git_odb_object_free(obj);
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to parse commit"); return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "Failed to parse commit");
} }
......
...@@ -162,7 +162,7 @@ static int retrieve_head_tree(git_tree **tree_out, git_repository *repo) ...@@ -162,7 +162,7 @@ static int retrieve_head_tree(git_tree **tree_out, git_repository *repo)
*tree_out = tree; *tree_out = tree;
exit: exit:
git_commit_close(head_commit); git_commit_free(head_commit);
return error; return error;
} }
...@@ -214,7 +214,7 @@ static int process_folder(struct status_st *st, const git_tree_entry *tree_entry ...@@ -214,7 +214,7 @@ static int process_folder(struct status_st *st, const git_tree_entry *tree_entry
} }
if (tree_entry_type == GIT_OBJ_TREE) { if (tree_entry_type == GIT_OBJ_TREE) {
git_object_close(subtree); git_object_free(subtree);
st->head_tree_relative_path_len -= 1 + tree_entry->filename_len; st->head_tree_relative_path_len -= 1 + tree_entry->filename_len;
st->tree = pushed_tree; st->tree = pushed_tree;
st->tree_position = pushed_tree_position; st->tree_position = pushed_tree_position;
...@@ -477,7 +477,7 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig ...@@ -477,7 +477,7 @@ int git_status_foreach(git_repository *repo, int (*callback)(const char *, unsig
exit: exit:
git_vector_free(&entries); git_vector_free(&entries);
git_tree_close(tree); git_tree_free(tree);
return error; return error;
} }
...@@ -512,7 +512,7 @@ static int recurse_tree_entry(git_tree *tree, struct status_entry *e, const char ...@@ -512,7 +512,7 @@ static int recurse_tree_entry(git_tree *tree, struct status_entry *e, const char
return git__throw(GIT_EOBJCORRUPTED, "Can't find tree object '%s'", tree_entry->filename); return git__throw(GIT_EOBJCORRUPTED, "Can't find tree object '%s'", tree_entry->filename);
error = recurse_tree_entry(subtree, e, dir_sep+1); error = recurse_tree_entry(subtree, e, dir_sep+1);
git_tree_close(subtree); git_tree_free(subtree);
return error; return error;
} }
...@@ -585,7 +585,7 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char ...@@ -585,7 +585,7 @@ int git_status_file(unsigned int *status_flags, git_repository *repo, const char
*status_flags = e->status_flags; *status_flags = e->status_flags;
exit: exit:
git_tree_close(tree); git_tree_free(tree);
git__free(e); git__free(e);
return error; return error;
} }
......
...@@ -319,7 +319,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu ...@@ -319,7 +319,7 @@ int git_tag_create_frombuffer(git_oid *oid, git_repository *repo, const char *bu
if (tag.type != target_obj->raw.type) if (tag.type != target_obj->raw.type)
return git__throw(error, "The type for the given target is invalid"); return git__throw(error, "The type for the given target is invalid");
git_odb_object_close(target_obj); git_odb_object_free(target_obj);
error = retrieve_tag_reference(&new_ref, ref_name, repo, tag.tag_name); error = retrieve_tag_reference(&new_ref, ref_name, repo, tag.tag_name);
......
...@@ -114,7 +114,7 @@ static int add_ref(const char *name, git_repository *repo, git_vector *vec) ...@@ -114,7 +114,7 @@ static int add_ref(const char *name, git_repository *repo, git_vector *vec)
git_reference_free(ref); git_reference_free(ref);
git_reference_free(resolved_ref); git_reference_free(resolved_ref);
git_object_close(obj); git_object_free(obj);
if (error < GIT_SUCCESS) { if (error < GIT_SUCCESS) {
git__free(head->name); git__free(head->name);
git__free(head); git__free(head);
......
...@@ -680,7 +680,7 @@ static int tree_frompath( ...@@ -680,7 +680,7 @@ static int tree_frompath(
slash_pos - treeentry_path + 1 slash_pos - treeentry_path + 1
); );
git_tree_close(subtree); git_tree_free(subtree);
return error; return error;
} }
...@@ -731,7 +731,7 @@ static int tree_walk_post( ...@@ -731,7 +731,7 @@ static int tree_walk_post(
payload payload
); );
git_tree_close(subtree); git_tree_free(subtree);
} }
} }
......
...@@ -19,7 +19,7 @@ void test_object_tree_frompath__initialize(void) ...@@ -19,7 +19,7 @@ void test_object_tree_frompath__initialize(void)
void test_object_tree_frompath__cleanup(void) void test_object_tree_frompath__cleanup(void)
{ {
git_tree_close(tree); git_tree_free(tree);
git_repository_free(repo); git_repository_free(repo);
cl_fixture_cleanup("testrepo.git"); cl_fixture_cleanup("testrepo.git");
} }
...@@ -37,7 +37,7 @@ static void assert_tree_from_path(git_tree *root, const char *path, git_error ex ...@@ -37,7 +37,7 @@ static void assert_tree_from_path(git_tree *root, const char *path, git_error ex
cl_assert(git_oid_streq(git_object_id((const git_object *)containing_tree), expected_raw_oid) == GIT_SUCCESS); cl_assert(git_oid_streq(git_object_id((const git_object *)containing_tree), expected_raw_oid) == GIT_SUCCESS);
git_tree_close(containing_tree); git_tree_free(containing_tree);
} }
void test_object_tree_frompath__retrieve_tree_from_path_to_treeentry(void) void test_object_tree_frompath__retrieve_tree_from_path_to_treeentry(void)
......
...@@ -39,7 +39,7 @@ static void test_read_object(object_data *data) ...@@ -39,7 +39,7 @@ static void test_read_object(object_data *data)
cmp_objects((git_rawobj *)&obj->raw, data); cmp_objects((git_rawobj *)&obj->raw, data);
git_odb_object_close(obj); git_odb_object_free(obj);
git_odb_free(odb); git_odb_free(odb);
} }
......
...@@ -26,7 +26,7 @@ void test_odb_packed__mass_read(void) ...@@ -26,7 +26,7 @@ void test_odb_packed__mass_read(void)
cl_assert(git_odb_exists(_odb, &id) == 1); cl_assert(git_odb_exists(_odb, &id) == 1);
cl_git_pass(git_odb_read(&obj, _odb, &id)); cl_git_pass(git_odb_read(&obj, _odb, &id));
git_odb_object_close(obj); git_odb_object_free(obj);
} }
} }
...@@ -48,7 +48,7 @@ void test_odb_packed__read_header_0(void) ...@@ -48,7 +48,7 @@ void test_odb_packed__read_header_0(void)
cl_assert(obj->raw.len == len); cl_assert(obj->raw.len == len);
cl_assert(obj->raw.type == type); cl_assert(obj->raw.type == type);
git_odb_object_close(obj); git_odb_object_free(obj);
} }
} }
...@@ -72,6 +72,7 @@ void test_odb_packed__read_header_1(void) ...@@ -72,6 +72,7 @@ void test_odb_packed__read_header_1(void)
cl_assert(obj->raw.len == len); cl_assert(obj->raw.len == len);
cl_assert(obj->raw.type == type); cl_assert(obj->raw.type == type);
git_odb_object_close(obj); git_odb_object_free(obj);
} }
} }
...@@ -113,7 +113,7 @@ BEGIN_TEST(write0, "write loose commit object") ...@@ -113,7 +113,7 @@ BEGIN_TEST(write0, "write loose commit object")
must_pass(git_odb_read(&obj, db, &id1)); must_pass(git_odb_read(&obj, db, &id1));
must_pass(cmp_objects(&obj->raw, &commit_obj)); must_pass(cmp_objects(&obj->raw, &commit_obj));
git_odb_object_close(obj); git_odb_object_free(obj);
git_odb_free(db); git_odb_free(db);
must_pass(remove_object_files(&commit)); must_pass(remove_object_files(&commit));
END_TEST END_TEST
...@@ -134,7 +134,7 @@ BEGIN_TEST(write1, "write loose tree object") ...@@ -134,7 +134,7 @@ BEGIN_TEST(write1, "write loose tree object")
must_pass(git_odb_read(&obj, db, &id1)); must_pass(git_odb_read(&obj, db, &id1));
must_pass(cmp_objects(&obj->raw, &tree_obj)); must_pass(cmp_objects(&obj->raw, &tree_obj));
git_odb_object_close(obj); git_odb_object_free(obj);
git_odb_free(db); git_odb_free(db);
must_pass(remove_object_files(&tree)); must_pass(remove_object_files(&tree));
END_TEST END_TEST
...@@ -155,7 +155,7 @@ BEGIN_TEST(write2, "write loose tag object") ...@@ -155,7 +155,7 @@ BEGIN_TEST(write2, "write loose tag object")
must_pass(git_odb_read(&obj, db, &id1)); must_pass(git_odb_read(&obj, db, &id1));
must_pass(cmp_objects(&obj->raw, &tag_obj)); must_pass(cmp_objects(&obj->raw, &tag_obj));
git_odb_object_close(obj); git_odb_object_free(obj);
git_odb_free(db); git_odb_free(db);
must_pass(remove_object_files(&tag)); must_pass(remove_object_files(&tag));
END_TEST END_TEST
...@@ -176,7 +176,7 @@ BEGIN_TEST(write3, "write zero-length object") ...@@ -176,7 +176,7 @@ BEGIN_TEST(write3, "write zero-length object")
must_pass(git_odb_read(&obj, db, &id1)); must_pass(git_odb_read(&obj, db, &id1));
must_pass(cmp_objects(&obj->raw, &zero_obj)); must_pass(cmp_objects(&obj->raw, &zero_obj));
git_odb_object_close(obj); git_odb_object_free(obj);
git_odb_free(db); git_odb_free(db);
must_pass(remove_object_files(&zero)); must_pass(remove_object_files(&zero));
END_TEST END_TEST
...@@ -197,7 +197,7 @@ BEGIN_TEST(write4, "write one-byte long object") ...@@ -197,7 +197,7 @@ BEGIN_TEST(write4, "write one-byte long object")
must_pass(git_odb_read(&obj, db, &id1)); must_pass(git_odb_read(&obj, db, &id1));
must_pass(cmp_objects(&obj->raw, &one_obj)); must_pass(cmp_objects(&obj->raw, &one_obj));
git_odb_object_close(obj); git_odb_object_free(obj);
git_odb_free(db); git_odb_free(db);
must_pass(remove_object_files(&one)); must_pass(remove_object_files(&one));
END_TEST END_TEST
...@@ -218,7 +218,7 @@ BEGIN_TEST(write5, "write two-byte long object") ...@@ -218,7 +218,7 @@ BEGIN_TEST(write5, "write two-byte long object")
must_pass(git_odb_read(&obj, db, &id1)); must_pass(git_odb_read(&obj, db, &id1));
must_pass(cmp_objects(&obj->raw, &two_obj)); must_pass(cmp_objects(&obj->raw, &two_obj));
git_odb_object_close(obj); git_odb_object_free(obj);
git_odb_free(db); git_odb_free(db);
must_pass(remove_object_files(&two)); must_pass(remove_object_files(&two));
END_TEST END_TEST
...@@ -239,7 +239,7 @@ BEGIN_TEST(write6, "write an object which is several bytes long") ...@@ -239,7 +239,7 @@ BEGIN_TEST(write6, "write an object which is several bytes long")
must_pass(git_odb_read(&obj, db, &id1)); must_pass(git_odb_read(&obj, db, &id1));
must_pass(cmp_objects(&obj->raw, &some_obj)); must_pass(cmp_objects(&obj->raw, &some_obj));
git_odb_object_close(obj); git_odb_object_free(obj);
git_odb_free(db); git_odb_free(db);
must_pass(remove_object_files(&some)); must_pass(remove_object_files(&some));
END_TEST END_TEST
......
...@@ -609,18 +609,18 @@ BEGIN_TEST(details0, "query the details on a parsed commit") ...@@ -609,18 +609,18 @@ BEGIN_TEST(details0, "query the details on a parsed commit")
must_be_true(parents <= 2); must_be_true(parents <= 2);
for (p = 0;p < parents;p++) { for (p = 0;p < parents;p++) {
if (old_parent != NULL) if (old_parent != NULL)
git_commit_close(old_parent); git_commit_free(old_parent);
old_parent = parent; old_parent = parent;
must_pass(git_commit_parent(&parent, commit, p)); must_pass(git_commit_parent(&parent, commit, p));
must_be_true(parent != NULL); must_be_true(parent != NULL);
must_be_true(git_commit_author(parent) != NULL); // is it really a commit? must_be_true(git_commit_author(parent) != NULL); // is it really a commit?
} }
git_commit_close(old_parent); git_commit_free(old_parent);
git_commit_close(parent); git_commit_free(parent);
must_fail(git_commit_parent(&parent, commit, parents)); must_fail(git_commit_parent(&parent, commit, parents));
git_commit_close(commit); git_commit_free(commit);
} }
git_repository_free(repo); git_repository_free(repo);
...@@ -665,8 +665,8 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk") ...@@ -665,8 +665,8 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk")
tree, tree,
1, parent)); 1, parent));
git_object_close((git_object *)parent); git_object_free((git_object *)parent);
git_object_close((git_object *)tree); git_object_free((git_object *)tree);
git_signature_free(committer); git_signature_free(committer);
git_signature_free(author); git_signature_free(author);
...@@ -696,7 +696,7 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk") ...@@ -696,7 +696,7 @@ BEGIN_TEST(write0, "write a new commit object from memory to disk")
must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit)); must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit));
git_commit_close(commit); git_commit_free(commit);
git_repository_free(repo); git_repository_free(repo);
END_TEST END_TEST
...@@ -742,7 +742,7 @@ BEGIN_TEST(root0, "create a root commit") ...@@ -742,7 +742,7 @@ BEGIN_TEST(root0, "create a root commit")
tree, tree,
0)); 0));
git_object_close((git_object *)tree); git_object_free((git_object *)tree);
git_signature_free(committer); git_signature_free(committer);
git_signature_free(author); git_signature_free(author);
...@@ -764,7 +764,7 @@ BEGIN_TEST(root0, "create a root commit") ...@@ -764,7 +764,7 @@ BEGIN_TEST(root0, "create a root commit")
must_pass(git_reference_delete(branch)); must_pass(git_reference_delete(branch));
must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit)); must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)commit));
git__free(head_old); git__free(head_old);
git_commit_close(commit); git_commit_free(commit);
git_repository_free(repo); git_repository_free(repo);
git_reference_free(head); git_reference_free(head);
......
...@@ -60,9 +60,9 @@ BEGIN_TEST(read0, "read and parse a tag from the repository") ...@@ -60,9 +60,9 @@ BEGIN_TEST(read0, "read and parse a tag from the repository")
must_be_true(git_oid_cmp(&id_commit, git_commit_id(commit)) == 0); must_be_true(git_oid_cmp(&id_commit, git_commit_id(commit)) == 0);
git_tag_close(tag1); git_tag_free(tag1);
git_tag_close(tag2); git_tag_free(tag2);
git_commit_close(commit); git_commit_free(commit);
git_repository_free(repo); git_repository_free(repo);
END_TEST END_TEST
...@@ -133,8 +133,8 @@ BEGIN_TEST(read3, "read and parse a tag without a tagger field") ...@@ -133,8 +133,8 @@ BEGIN_TEST(read3, "read and parse a tag without a tagger field")
must_be_true(git_oid_cmp(&id_commit, git_commit_id(commit)) == 0); must_be_true(git_oid_cmp(&id_commit, git_commit_id(commit)) == 0);
git_tag_close(bad_tag); git_tag_free(bad_tag);
git_commit_close(commit); git_commit_free(commit);
git_repository_free(repo); git_repository_free(repo);
END_TEST END_TEST
...@@ -170,7 +170,7 @@ BEGIN_TEST(write0, "write a tag to the repository and read it again") ...@@ -170,7 +170,7 @@ BEGIN_TEST(write0, "write a tag to the repository and read it again")
TAGGER_MESSAGE, TAGGER_MESSAGE,
0)); 0));
git_object_close(target); git_object_free(target);
git_signature_free(tagger); git_signature_free(tagger);
must_pass(git_tag_lookup(&tag, repo, &tag_id)); must_pass(git_tag_lookup(&tag, repo, &tag_id));
...@@ -195,7 +195,7 @@ BEGIN_TEST(write0, "write a tag to the repository and read it again") ...@@ -195,7 +195,7 @@ BEGIN_TEST(write0, "write a tag to the repository and read it again")
must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)tag)); must_pass(remove_loose_object(REPOSITORY_FOLDER, (git_object *)tag));
git_tag_close(tag); git_tag_free(tag);
git_repository_free(repo); git_repository_free(repo);
END_TEST END_TEST
...@@ -222,7 +222,7 @@ BEGIN_TEST(write2, "Attempt to write a tag bearing the same name than an already ...@@ -222,7 +222,7 @@ BEGIN_TEST(write2, "Attempt to write a tag bearing the same name than an already
TAGGER_MESSAGE, TAGGER_MESSAGE,
0)); 0));
git_object_close(target); git_object_free(target);
git_signature_free(tagger); git_signature_free(tagger);
git_repository_free(repo); git_repository_free(repo);
...@@ -256,7 +256,7 @@ BEGIN_TEST(write3, "Replace an already existing tag") ...@@ -256,7 +256,7 @@ BEGIN_TEST(write3, "Replace an already existing tag")
TAGGER_MESSAGE, TAGGER_MESSAGE,
1)); 1));
git_object_close(target); git_object_free(target);
git_signature_free(tagger); git_signature_free(tagger);
must_pass(git_reference_lookup(&ref_tag, repo, "refs/tags/e90810b")); must_pass(git_reference_lookup(&ref_tag, repo, "refs/tags/e90810b"));
...@@ -286,7 +286,7 @@ BEGIN_TEST(write4, "write a lightweight tag to the repository and read it again" ...@@ -286,7 +286,7 @@ BEGIN_TEST(write4, "write a lightweight tag to the repository and read it again"
target, target,
0)); 0));
git_object_close(target); git_object_free(target);
must_be_true(git_oid_cmp(&object_id, &target_id) == 0); must_be_true(git_oid_cmp(&object_id, &target_id) == 0);
...@@ -320,7 +320,7 @@ BEGIN_TEST(write5, "Attempt to write a lightweight tag bearing the same name tha ...@@ -320,7 +320,7 @@ BEGIN_TEST(write5, "Attempt to write a lightweight tag bearing the same name tha
git_oid_fromstr(&existing_object_id, tag2_id); git_oid_fromstr(&existing_object_id, tag2_id);
must_be_true(git_oid_cmp(&object_id, &existing_object_id) == 0); must_be_true(git_oid_cmp(&object_id, &existing_object_id) == 0);
git_object_close(target); git_object_free(target);
git_repository_free(repo); git_repository_free(repo);
END_TEST END_TEST
......
...@@ -53,13 +53,13 @@ static int print_tree(git_repository *repo, const git_oid *tree_oid, int depth) ...@@ -53,13 +53,13 @@ static int print_tree(git_repository *repo, const git_oid *tree_oid, int depth)
if (entry->attr == S_IFDIR) { if (entry->attr == S_IFDIR) {
if (print_tree(repo, &entry->oid, depth + 1) < GIT_SUCCESS) { if (print_tree(repo, &entry->oid, depth + 1) < GIT_SUCCESS) {
git_tree_close(tree); git_tree_free(tree);
return GIT_ERROR; return GIT_ERROR;
} }
} }
} }
git_tree_close(tree); git_tree_free(tree);
return GIT_SUCCESS; return GIT_SUCCESS;
} }
#endif #endif
...@@ -83,7 +83,7 @@ BEGIN_TEST(read0, "acces randomly the entries on a loaded tree") ...@@ -83,7 +83,7 @@ BEGIN_TEST(read0, "acces randomly the entries on a loaded tree")
must_be_true(git_tree_entry_byindex(tree, 3) == NULL); must_be_true(git_tree_entry_byindex(tree, 3) == NULL);
must_be_true(git_tree_entry_byindex(tree, (unsigned int)-1) == NULL); must_be_true(git_tree_entry_byindex(tree, (unsigned int)-1) == NULL);
git_tree_close(tree); git_tree_free(tree);
git_repository_free(repo); git_repository_free(repo);
END_TEST END_TEST
...@@ -105,7 +105,7 @@ BEGIN_TEST(read1, "read a tree from the repository") ...@@ -105,7 +105,7 @@ BEGIN_TEST(read1, "read a tree from the repository")
/* GH-86: git_object_lookup() should also check the type if the object comes from the cache */ /* GH-86: git_object_lookup() should also check the type if the object comes from the cache */
must_be_true(git_object_lookup(&obj, repo, &id, GIT_OBJ_TREE) == 0); must_be_true(git_object_lookup(&obj, repo, &id, GIT_OBJ_TREE) == 0);
must_be_true(obj != NULL); must_be_true(obj != NULL);
git_object_close(obj); git_object_free(obj);
obj = NULL; obj = NULL;
must_be_true(git_object_lookup(&obj, repo, &id, GIT_OBJ_BLOB) == GIT_EINVALIDTYPE); must_be_true(git_object_lookup(&obj, repo, &id, GIT_OBJ_BLOB) == GIT_EINVALIDTYPE);
must_be_true(obj == NULL); must_be_true(obj == NULL);
...@@ -118,8 +118,8 @@ BEGIN_TEST(read1, "read a tree from the repository") ...@@ -118,8 +118,8 @@ BEGIN_TEST(read1, "read a tree from the repository")
must_pass(git_tree_entry_2object(&obj, repo, entry)); must_pass(git_tree_entry_2object(&obj, repo, entry));
must_be_true(obj != NULL); must_be_true(obj != NULL);
git_object_close(obj); git_object_free(obj);
git_tree_close(tree); git_tree_free(tree);
git_repository_free(repo); git_repository_free(repo);
END_TEST END_TEST
...@@ -164,7 +164,7 @@ BEGIN_TEST(write2, "write a tree from a memory") ...@@ -164,7 +164,7 @@ BEGIN_TEST(write2, "write a tree from a memory")
must_be_true(git_oid_cmp(&rid, &id2) == 0); must_be_true(git_oid_cmp(&rid, &id2) == 0);
git_treebuilder_free(builder); git_treebuilder_free(builder);
git_tree_close(tree); git_tree_free(tree);
close_temp_repo(repo); close_temp_repo(repo);
END_TEST END_TEST
...@@ -193,7 +193,7 @@ BEGIN_TEST(write3, "write a hierarchical tree from a memory") ...@@ -193,7 +193,7 @@ BEGIN_TEST(write3, "write a hierarchical tree from a memory")
must_pass(git_treebuilder_insert(NULL,builder,"new",&subtree_id,040000)); must_pass(git_treebuilder_insert(NULL,builder,"new",&subtree_id,040000));
must_pass(git_treebuilder_write(&id_hiearar,repo,builder)); must_pass(git_treebuilder_write(&id_hiearar,repo,builder));
git_treebuilder_free(builder); git_treebuilder_free(builder);
git_tree_close(tree); git_tree_free(tree);
must_be_true(git_oid_cmp(&id_hiearar, &id3) == 0); must_be_true(git_oid_cmp(&id_hiearar, &id3) == 0);
...@@ -204,7 +204,7 @@ BEGIN_TEST(write3, "write a hierarchical tree from a memory") ...@@ -204,7 +204,7 @@ BEGIN_TEST(write3, "write a hierarchical tree from a memory")
must_be_true((loose_object_dir_mode(TEMP_REPO_FOLDER, (git_object *)tree) & 0777) == GIT_OBJECT_DIR_MODE); must_be_true((loose_object_dir_mode(TEMP_REPO_FOLDER, (git_object *)tree) & 0777) == GIT_OBJECT_DIR_MODE);
must_be_true((loose_object_mode(TEMP_REPO_FOLDER, (git_object *)tree) & 0777) == GIT_OBJECT_FILE_MODE); must_be_true((loose_object_mode(TEMP_REPO_FOLDER, (git_object *)tree) & 0777) == GIT_OBJECT_FILE_MODE);
#endif #endif
git_tree_close(tree); git_tree_free(tree);
close_temp_repo(repo); close_temp_repo(repo);
......
...@@ -54,7 +54,7 @@ BEGIN_TEST(readtag0, "lookup a loose tag reference") ...@@ -54,7 +54,7 @@ BEGIN_TEST(readtag0, "lookup a loose tag reference")
git_path_join(ref_name_from_tag_name, GIT_REFS_TAGS_DIR, git_tag_name((git_tag *)object)); git_path_join(ref_name_from_tag_name, GIT_REFS_TAGS_DIR, git_tag_name((git_tag *)object));
must_be_true(strcmp(ref_name_from_tag_name, loose_tag_ref_name) == 0); must_be_true(strcmp(ref_name_from_tag_name, loose_tag_ref_name) == 0);
git_object_close(object); git_object_free(object);
git_repository_free(repo); git_repository_free(repo);
git_reference_free(reference); git_reference_free(reference);
...@@ -99,7 +99,7 @@ BEGIN_TEST(readsym0, "lookup a symbolic reference") ...@@ -99,7 +99,7 @@ BEGIN_TEST(readsym0, "lookup a symbolic reference")
git_oid_fromstr(&id, current_master_tip); git_oid_fromstr(&id, current_master_tip);
must_be_true(git_oid_cmp(&id, git_object_id(object)) == 0); must_be_true(git_oid_cmp(&id, git_object_id(object)) == 0);
git_object_close(object); git_object_free(object);
git_repository_free(repo); git_repository_free(repo);
git_reference_free(reference); git_reference_free(reference);
...@@ -129,7 +129,7 @@ BEGIN_TEST(readsym1, "lookup a nested symbolic reference") ...@@ -129,7 +129,7 @@ BEGIN_TEST(readsym1, "lookup a nested symbolic reference")
git_oid_fromstr(&id, current_master_tip); git_oid_fromstr(&id, current_master_tip);
must_be_true(git_oid_cmp(&id, git_object_id(object)) == 0); must_be_true(git_oid_cmp(&id, git_object_id(object)) == 0);
git_object_close(object); git_object_free(object);
git_repository_free(repo); git_repository_free(repo);
git_reference_free(reference); git_reference_free(reference);
...@@ -200,7 +200,7 @@ BEGIN_TEST(readpacked0, "lookup a packed reference") ...@@ -200,7 +200,7 @@ BEGIN_TEST(readpacked0, "lookup a packed reference")
must_be_true(object != NULL); must_be_true(object != NULL);
must_be_true(git_object_type(object) == GIT_OBJ_COMMIT); must_be_true(git_object_type(object) == GIT_OBJ_COMMIT);
git_object_close(object); git_object_free(object);
git_repository_free(repo); git_repository_free(repo);
git_reference_free(reference); git_reference_free(reference);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment