@@ -247,6 +247,11 @@ static void object_database(git_repository *repo, git_oid *oid)
247247 */
248248 git_oid_fmt (oid_hex , oid );
249249 printf ("Written Object: %s\n" , oid_hex );
250+
251+ /**
252+ * Free the object database after usage.
253+ */
254+ git_odb_free (odb );
250255}
251256
252257/**
@@ -312,6 +317,14 @@ static void commit_writing(git_repository *repo)
312317 */
313318 git_oid_fmt (oid_hex , & commit_id );
314319 printf ("New Commit: %s\n" , oid_hex );
320+
321+ /**
322+ * Free all objects used in the meanwhile.
323+ */
324+ git_tree_free (tree );
325+ git_commit_free (parent );
326+ git_signature_free (author );
327+ git_signature_free (committer );
315328}
316329
317330/**
@@ -431,7 +444,11 @@ static void tag_parsing(git_repository *repo)
431444 printf ("Tag Name: %s\nTag Type: %s\nTag Message: %s\n" ,
432445 name , git_object_type2string (type ), message );
433446
447+ /**
448+ * Free both the commit and tag after usage.
449+ */
434450 git_commit_free (commit );
451+ git_tag_free (tag );
435452}
436453
437454/**
@@ -485,9 +502,10 @@ static void tree_parsing(git_repository *repo)
485502 git_tree_entry_to_object (& obj , repo , entry ); /* blob */
486503
487504 /**
488- * Remember to close the looked-up object once you are done using it
505+ * Remember to close the looked-up object and tree once you are done using it
489506 */
490507 git_object_free (obj );
508+ git_tree_free (tree );
491509}
492510
493511/**
@@ -522,6 +540,11 @@ static void blob_parsing(git_repository *repo)
522540 * */
523541 printf ("Blob Size: %ld\n" , (long )git_blob_rawsize (blob )); /* 8 */
524542 git_blob_rawcontent (blob ); /* "content" */
543+
544+ /**
545+ * Free the blob after usage.
546+ */
547+ git_blob_free (blob );
525548}
526549
527550/**
@@ -716,4 +739,10 @@ static void config_files(const char *repo_path, git_repository* repo)
716739 check_error (git_repository_config_snapshot (& snap_cfg , repo ), "config snapshot" );
717740 git_config_get_string (& email , snap_cfg , "user.email" );
718741 printf ("Email: %s\n" , email );
742+
743+ /**
744+ * Remember to free the configurations after usage.
745+ */
746+ git_config_free (cfg );
747+ git_config_free (snap_cfg );
719748}
0 commit comments